m&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var b=+M(s=n[g],g),_=+x(s,g);v>b&&(v=b),d>_&&(d=_),b>m&&(m=b),_>y&&(y=_),f.push(b),h.push(_)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=su();if(k.add=function(n){i(k,n,+M(n,++g),+x(n,g),v,d,m,y)},k.visit=function(n){fu(n,k,v,d,m,y)},k.find=function(n){return hu(k,n[0],n[1],v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=hl.get(e)||fl,r=gl.get(r)||Et,Mu(r(e.apply(null,ea.call(arguments,1))))},ta.interpolateHcl=Lu,ta.interpolateHsl=Tu,ta.interpolateLab=Ru,ta.interpolateRound=Du,ta.transform=function(n){var t=ua.createElementNS(ta.ns.prefix.svg,"g");return(ta.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Pu(e?e.matrix:pl)})(n)},Pu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pl={a:1,b:0,c:0,d:1,e:0,f:0};ta.interpolateTransform=Hu,ta.layout={},ta.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var l=t.charge/c;n.px-=i*l,n.py-=o*l}return!0}if(t.point&&c&&p>c){var l=t.pointCharge/c;n.px-=i*l,n.py-=o*l}}return!t.charge}}function t(n){n.px=ta.event.x,n.py=ta.event.y,a.resume()}var e,r,u,i,o,a={},c=ta.dispatch("start","tick","end"),l=[1,1],s=.9,f=vl,h=dl,g=-30,p=ml,v=.1,d=.64,m=[],y=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,M,x,b=m.length,_=y.length;for(e=0;_>e;++e)a=y[e],f=a.source,h=a.target,M=h.x-f.x,x=h.y-f.y,(p=M*M+x*x)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,M*=p,x*=p,h.x-=M*(d=f.weight/(h.weight+f.weight)),h.y-=x*d,f.x+=M*(d=1-d),f.y+=x*d);if((d=r*v)&&(M=l[0]/2,x=l[1]/2,e=-1,d))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ta.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;l>a;++a){var u=y[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,l=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;s>t;++t)r=y[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;s>t;++t)u[t]=+f.call(this,y[t],t);else for(t=0;s>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;s>t;++t)i[t]=+h.call(this,y[t],t);else for(t=0;s>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=ta.behavior.drag().origin(Et).on("dragstart.force",Xu).on("drag.force",t).on("dragend.force",$u)),arguments.length?(this.on("mouseover.force",Bu).on("mouseout.force",Wu).call(e),void 0):e},ta.rebind(a,c,"on")};var vl=20,dl=1,ml=1/0;ta.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(l=e.call(n,i,i.depth))&&(c=l.length)){for(var c,l,s;--c>=0;)o.push(s=l[c]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=l}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Qu(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=ei,e=ni,r=ti;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ku(t,function(n){n.children&&(n.value=0)}),Qu(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ta.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),p=(f-c*g)/ta.sum(l),v=ta.range(c),d=[];return null!=e&&v.sort(e===yl?function(n,t){return l[t]-l[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){d[n]={data:o[n],value:a=l[n],startAngle:s,endAngle:s+=a*p+g,padAngle:h}}),d}var t=Number,e=yl,r=0,u=Pa,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var yl={};ta.layout.stack=function(){function n(a,c){if(!(h=a.length))return a;var l=a.map(function(e,r){return t.call(n,e,r)}),s=l.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),f=e.call(n,s,c);l=ta.permute(l,f),s=ta.permute(s,f);var h,g,p,v,d=r.call(n,s,c),m=l[0].length;for(p=0;m>p;++p)for(u.call(n,l[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,l[g][p],v+=s[g-1][p][1],s[g][p][1]);return a}var t=Et,e=ai,r=ci,u=oi,i=ui,o=ii;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:Ml.get(t)||ai,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:xl.get(t)||ci,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var Ml=ta.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(li),i=n.map(si),o=ta.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,l=[],s=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],l.push(e)):(c+=i[e],s.push(e));return s.reverse().concat(l)},reverse:function(n){return ta.range(n.length).reverse()},"default":ai}),xl=ta.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,l,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];s>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ci});ta.layout.histogram=function(){function n(n,i){for(var o,a,c=[],l=n.map(e,this),s=r.call(this,l,i),f=u.call(this,s,l,i),i=-1,h=l.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&a<=s[1]&&(o=c[ta.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=pi,u=hi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return gi(n,t)}:kt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ta.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],l=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Qu(a,function(n){n.r=+s(n.value)}),Qu(a,Mi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/l))/2;Qu(a,function(n){n.r+=f}),Qu(a,Mi),Qu(a,function(n){n.r-=f})}return _i(a,c/2,l/2,t?1:1/Math.max(2*a.r/c,2*a.r/l)),o}var t,e=ta.layout.hierarchy().sort(vi),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Gu(n,e)},ta.layout.tree=function(){function n(n,u){var s=o.call(this,n,u),f=s[0],h=t(f);if(Qu(h,e),h.parent.m=-h.z,Ku(h,r),l)Ku(f,i);else{var g=f,p=f,v=f;Ku(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);Ku(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Ni(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],l=u.m,s=i.m,f=o.m,h=c.m;o=Ei(o),u=ki(u),o&&u;)c=ki(c),i=Ei(i),i.a=n,r=o.z+f-u.z-l+a(o._,u._),r>0&&(Ai(Ci(o,n,e),n,r),l+=r,s+=r),f+=o.m,l+=u.m,h+=c.m,s+=i.m;o&&!Ei(i)&&(i.t=o,i.m+=f-s),u&&!ki(c)&&(c.t=u,c.m+=l-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=ta.layout.hierarchy().sort(null).value(null),a=Si,c=[1,1],l=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(l=null==(c=t)?i:null,n):l?null:c},n.nodeSize=function(t){return arguments.length?(l=null==(c=t)?null:i,n):l?c:null},Gu(n,o)},ta.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],l=0;Qu(c,function(n){var t=n.children;t&&t.length?(n.x=qi(t),n.y=zi(t)):(n.x=o?l+=e(n,o):0,n.y=0,o=n)});var s=Li(c),f=Ti(c),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return Qu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=ta.layout.hierarchy().sort(null).value(null),e=Si,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Gu(n,t)},ta.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,l=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),s.area=0;(c=h.length)>0;)s.push(o=h[c-1]),s.area+=o.area,"squarify"!==g||(a=r(s,v))<=p?(h.pop(),p=a):(s.area-=s.pop().area,u(s,v,l,!1),v=Math.min(l.dx,l.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,l,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,l=e.y,s=t?c(n.area/t):0;if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=ta.random.normal.apply(ta,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ta.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ta.scale={};var bl={floor:Et,ceil:Et};ta.scale.linear=function(){return Yi([0,1],[0,1],mu,!1)};var _l={s:1,g:1,p:1,r:1,e:1};ta.scale.log=function(){return Ji(ta.scale.linear().domain([0,1]),10,!0,[1,10])};var wl=ta.format(".0e"),Sl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ta.scale.pow=function(){return Gi(ta.scale.linear(),1,[0,1])},ta.scale.sqrt=function(){return ta.scale.pow().exponent(.5)},ta.scale.ordinal=function(){return Qi([],{t:"range",a:[[]]})},ta.scale.category10=function(){return ta.scale.ordinal().range(kl)},ta.scale.category20=function(){return ta.scale.ordinal().range(El)},ta.scale.category20b=function(){return ta.scale.ordinal().range(Al)},ta.scale.category20c=function(){return ta.scale.ordinal().range(Nl)};var kl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yt),El=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yt),Al=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yt),Nl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yt);ta.scale.quantile=function(){return no([],[])},ta.scale.quantize=function(){return to(0,1,[0,1])},ta.scale.threshold=function(){return eo([.5],[0,1])},ta.scale.identity=function(){return ro([0,1])},ta.svg={},ta.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),s=o.apply(this,arguments)-ja,f=a.apply(this,arguments)-ja,h=Math.abs(f-s),g=s>f?0:1;if(n>l&&(p=l,l=n,n=p),h>=Ua)return t(l,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,E=0,A=0,N=[];if((m=(+c.apply(this,arguments)||0)/2)&&(d=i===Cl?Math.sqrt(n*n+l*l):+i.apply(this,arguments),g||(A*=-1),l&&(A=nt(d/l*Math.sin(m))),n&&(E=nt(d/n*Math.sin(m)))),l){y=l*Math.cos(s+A),M=l*Math.sin(s+A),x=l*Math.cos(f-A),b=l*Math.sin(f-A);var C=Math.abs(f-s-2*A)<=Da?0:1;if(A&&so(y,M,x,b)===g^C){var z=(s+f)/2;y=l*Math.cos(z),M=l*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-E),w=n*Math.sin(f-E),S=n*Math.cos(s+E),k=n*Math.sin(s+E);var q=Math.abs(s-f+2*E)<=Da?0:1;if(E&&so(_,w,S,k)===1-g^q){var L=(s+f)/2;_=n*Math.cos(L),w=n*Math.sin(L),S=k=null}}else _=w=0;if((p=Math.min(Math.abs(l-n)/2,+u.apply(this,arguments)))>.001){v=l>n^g?0:1;var T=null==S?[_,w]:null==x?[y,M]:Lr([y,M],[S,k],[x,b],[_,w]),R=y-T[0],D=M-T[1],P=x-T[0],U=b-T[1],j=1/Math.sin(Math.acos((R*P+D*U)/(Math.sqrt(R*R+D*D)*Math.sqrt(P*P+U*U)))/2),F=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(null!=x){var H=Math.min(p,(l-F)/(j+1)),O=fo(null==S?[_,w]:[S,k],[y,M],l,H,g),Y=fo([x,b],[_,w],l,H,g);p===H?N.push("M",O[0],"A",H,",",H," 0 0,",v," ",O[1],"A",l,",",l," 0 ",1-g^so(O[1][0],O[1][1],Y[1][0],Y[1][1]),",",g," ",Y[1],"A",H,",",H," 0 0,",v," ",Y[0]):N.push("M",O[0],"A",H,",",H," 0 1,",v," ",Y[0])}else N.push("M",y,",",M);if(null!=S){var I=Math.min(p,(n-F)/(j-1)),Z=fo([y,M],[S,k],n,-I,g),V=fo([_,w],null==x?[y,M]:[x,b],n,-I,g);p===I?N.push("L",V[0],"A",I,",",I," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^so(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",I,",",I," 0 0,",v," ",Z[0]):N.push("L",V[0],"A",I,",",I," 0 0,",v," ",Z[0])}else N.push("L",_,",",w)}else N.push("M",y,",",M),null!=x&&N.push("A",l,",",l," 0 ",C,",",g," ",x,",",b),N.push("L",_,",",w),null!=S&&N.push("A",n,",",n," 0 ",q,",",1-g," ",S,",",k);return N.push("Z"),N.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=io,r=oo,u=uo,i=Cl,o=ao,a=co,c=lo;return n.innerRadius=function(t){return arguments.length?(e=kt(t),n):e},n.outerRadius=function(t){return arguments.length?(r=kt(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=kt(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==Cl?Cl:kt(t),n):i},n.startAngle=function(t){return arguments.length?(o=kt(t),n):o},n.endAngle=function(t){return arguments.length?(a=kt(t),n):a},n.padAngle=function(t){return arguments.length?(c=kt(t),n):c},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-ja;return[Math.cos(t)*n,Math.sin(t)*n]},n};var Cl="auto";ta.svg.line=function(){return ho(Et)};var zl=ta.map({linear:go,"linear-closed":po,step:vo,"step-before":mo,"step-after":yo,basis:So,"basis-open":ko,"basis-closed":Eo,bundle:Ao,cardinal:bo,"cardinal-open":Mo,"cardinal-closed":xo,monotone:To});zl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var ql=[0,2/3,1/3,0],Ll=[0,1/3,2/3,0],Tl=[0,1/6,2/3,1/6];ta.svg.line.radial=function(){var n=ho(Ro);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},mo.reverse=yo,yo.reverse=mo,ta.svg.area=function(){return Do(Et)},ta.svg.area.radial=function(){var n=Do(Ro);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ta.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),l=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+u(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)-ja,s=l.call(n,u,r)-ja;return{r:i,a0:o,a1:s,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Da)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=mr,o=yr,a=Po,c=ao,l=co;return n.radius=function(t){return arguments.length?(a=kt(t),n):a},n.source=function(t){return arguments.length?(i=kt(t),n):i},n.target=function(t){return arguments.length?(o=kt(t),n):o},n.startAngle=function(t){return arguments.length?(c=kt(t),n):c},n.endAngle=function(t){return arguments.length?(l=kt(t),n):l},n},ta.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=mr,e=yr,r=Uo;return n.source=function(e){return arguments.length?(t=kt(e),n):t},n.target=function(t){return arguments.length?(e=kt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ta.svg.diagonal.radial=function(){var n=ta.svg.diagonal(),t=Uo,e=n.projection;return n.projection=function(n){return arguments.length?e(jo(t=n)):t},n},ta.svg.symbol=function(){function n(n,r){return(Rl.get(t.call(this,n,r))||Oo)(e.call(this,n,r))}var t=Ho,e=Fo;return n.type=function(e){return arguments.length?(t=kt(e),n):t},n.size=function(t){return arguments.length?(e=kt(t),n):e},n};var Rl=ta.map({circle:Oo,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Pl)),e=t*Pl;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ta.svg.symbolTypes=Rl.keys();var Dl=Math.sqrt(3),Pl=Math.tan(30*Fa);ka.transition=function(n){for(var t,e,r=Ul||++Ol,u=Xo(n),i=[],o=jl||{time:Date.now(),ease:Su,delay:0,duration:250},a=-1,c=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Io(u,this.namespace,this.id)},Hl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):H(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Hl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Hu:mu,a=ta.ns.qualify(n);return Zo(this,"attr."+n,t,a.local?i:u)},Hl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=ta.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Hl.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=oa.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=mu(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return Zo(this,"style."+n,t,u)},Hl.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,oa.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Hl.text=function(n){return Zo(this,"text",n,Vo)},Hl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Hl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ta.ease.apply(ta,arguments)),H(this,function(r){r[e][t].ease=n}))},Hl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:H(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Hl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:H(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Hl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=jl,i=Ul;try{Ul=e,H(this,function(t,u,i){jl=t[r][e],n.call(t,t.__data__,u,i)})}finally{jl=u,Ul=i}}else H(this,function(u){var i=u[r][e];(i.event||(i.event=ta.dispatch("start","end","interrupt"))).on(n,t)});return this},Hl.transition=function(){for(var n,t,e,r,u=this.id,i=++Ol,o=this.namespace,a=[],c=0,l=this.length;l>c;c++){a.push(n=[]);for(var t=this[c],s=0,f=t.length;f>s;s++)(e=t[s])&&(r=e[o][u],$o(e,s,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Io(a,o,i)},ta.svg.axis=function(){function n(n){n.each(function(){var n,l=ta.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):Et:t,p=l.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Ta),d=ta.transition(p.exit()).style("opacity",Ta).remove(),m=ta.transition(p.order()).style("opacity",1),y=Math.max(u,0)+o,M=Ui(f),x=l.selectAll(".domain").data([0]),b=(x.enter().append("path").attr("class","domain"),ta.transition(x));v.append("line"),v.append("text");var _,w,S,k,E=v.select("line"),A=m.select("line"),N=p.select("text").text(g),C=v.select("text"),z=m.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Bo,_="x",S="y",w="x2",k="y2",N.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+M[0]+","+q*i+"V0H"+M[1]+"V"+q*i)):(n=Wo,_="y",S="x",w="y2",k="x2",N.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),b.attr("d","M"+q*i+","+M[0]+"H0V"+M[1]+"H"+q*i)),E.attr(k,q*u),C.attr(S,q*y),A.attr(w,0).attr(k,q*u),z.attr(_,0).attr(S,q*y),f.rangeBand){var L=f,T=L.rangeBand()/2;s=f=function(n){return L(n)+T}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=ta.scale.linear(),r=Yl,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Il?t+"":Yl,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Yl="bottom",Il={top:1,right:1,bottom:1,left:1};ta.svg.brush=function(){function n(i){i.each(function(){var i=ta.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(p,Et);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Zl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var s,f=ta.transition(i),h=ta.transition(o);c&&(s=Ui(c),h.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),l&&(s=Ui(l),h.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+f[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function r(n){n.select(".extent").attr("y",f[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function u(){function u(){32==ta.event.keyCode&&(N||(y=null,z[0]-=s[1],z[1]-=f[1],N=2),b())}function p(){32==ta.event.keyCode&&2==N&&(z[0]+=s[1],z[1]+=f[1],N=0,b())}function v(){var n=ta.mouse(x),u=!1;M&&(n[0]+=M[0],n[1]+=M[1]),N||(ta.event.altKey?(y||(y=[(s[0]+s[1])/2,(f[0]+f[1])/2]),z[0]=s[+(n[0]p?(u=r,r=p):u=p),v[0]!=r||v[1]!=u?(e?o=null:i=null,v[0]=r,v[1]=u,!0):void 0}function m(){v(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ta.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),w({type:"brushend"})}var y,M,x=this,_=ta.select(ta.event.target),w=a.of(x,arguments),S=ta.select(x),k=_.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&l,N=_.classed("extent"),C=X(),z=ta.mouse(x),q=ta.select(oa).on("keydown.brush",u).on("keyup.brush",p);if(ta.event.changedTouches?q.on("touchmove.brush",v).on("touchend.brush",m):q.on("mousemove.brush",v).on("mouseup.brush",m),S.interrupt().selectAll("*").interrupt(),N)z[0]=s[0]-z[0],z[1]=f[0]-z[1];else if(k){var L=+/w$/.test(k),T=+/^n/.test(k);M=[s[1-L]-z[0],f[1-T]-z[1]],z[0]=s[L],z[1]=f[T]}else ta.event.altKey&&(y=z.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),ta.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),v()}var i,o,a=w(n,"brushstart","brush","brushend"),c=null,l=null,s=[0,0],f=[0,0],h=!0,g=!0,p=Vl[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:s,y:f,i:i,j:o},e=this.__chart__||t;this.__chart__=t,Ul?ta.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,s=e.x,f=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=yu(s,t.x),r=yu(f,t.y);return i=o=null,function(u){s=t.x=e(u),f=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,p=Vl[!c<<1|!l],n):c},n.y=function(t){return arguments.length?(l=t,p=Vl[!c<<1|!l],n):l},n.clamp=function(t){return arguments.length?(c&&l?(h=!!t[0],g=!!t[1]):c?h=!!t:l&&(g=!!t),n):c&&l?[h,g]:c?h:l?g:null},n.extent=function(t){var e,r,u,a,h;return arguments.length?(c&&(e=t[0],r=t[1],l&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(h=e,e=r,r=h),(e!=s[0]||r!=s[1])&&(s=[e,r])),l&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],l.invert&&(u=l(u),a=l(a)),u>a&&(h=u,u=a,a=h),(u!=f[0]||a!=f[1])&&(f=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(h=e,e=r,r=h))),l&&(o?(u=o[0],a=o[1]):(u=f[0],a=f[1],l.invert&&(u=l.invert(u),a=l.invert(a)),u>a&&(h=u,u=a,a=h))),c&&l?[[e,u],[r,a]]:c?[e,r]:l&&[u,a])},n.clear=function(){return n.empty()||(s=[0,0],f=[0,0],i=o=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!l&&f[0]==f[1]},ta.rebind(n,a,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Vl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Xl=fc.format=mc.timeFormat,$l=Xl.utc,Bl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Xl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Jo:Bl,Jo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Jo.toString=Bl.toString,fc.second=Ft(function(n){return new hc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),fc.seconds=fc.second.range,fc.seconds.utc=fc.second.utc.range,fc.minute=Ft(function(n){return new hc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),fc.minutes=fc.minute.range,fc.minutes.utc=fc.minute.utc.range,fc.hour=Ft(function(n){var t=n.getTimezoneOffset()/60;return new hc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),fc.hours=fc.hour.range,fc.hours.utc=fc.hour.utc.range,fc.month=Ft(function(n){return n=fc.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),fc.months=fc.month.range,fc.months.utc=fc.month.utc.range;var Wl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Jl=[[fc.second,1],[fc.second,5],[fc.second,15],[fc.second,30],[fc.minute,1],[fc.minute,5],[fc.minute,15],[fc.minute,30],[fc.hour,1],[fc.hour,3],[fc.hour,6],[fc.hour,12],[fc.day,1],[fc.day,2],[fc.week,1],[fc.month,1],[fc.month,3],[fc.year,1]],Gl=Xl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Ne]]),Kl={range:function(n,t,e){return ta.range(Math.ceil(n/e)*e,+t,e).map(Ko)},floor:Et,ceil:Et};Jl.year=fc.year,fc.scale=function(){return Go(ta.scale.linear(),Jl,Gl)};var Ql=Jl.map(function(n){return[n[0].utc,n[1]]}),ns=$l.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Ne]]);Ql.year=fc.year.utc,fc.scale.utc=function(){return Go(ta.scale.linear(),Ql,ns)},ta.text=At(function(n){return n.responseText}),ta.json=function(n,t){return Nt(n,"application/json",Qo,t)},ta.html=function(n,t){return Nt(n,"text/html",na,t)},ta.xml=At(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(ta):"object"==typeof module&&module.exports&&(module.exports=ta),this.d3=ta}();
\ No newline at end of file
diff --git a/nengo_gui/static/lib/js/interact-1.2.4.js b/nengo_gui/static/lib/js/interact-1.2.4.js
deleted file mode 100644
index 393bec6e..00000000
--- a/nengo_gui/static/lib/js/interact-1.2.4.js
+++ /dev/null
@@ -1,5840 +0,0 @@
-/**
- * interact.js v1.2.4
- *
- * Copyright (c) 2012-2015 Taye Adeyemi
- * Open source under the MIT License.
- * https://raw.github.com/taye/interact.js/master/LICENSE
- */
-(function (realWindow) {
- 'use strict';
-
- // return early if there's no window to work with (eg. Node.js)
- if (!realWindow) { return; }
-
- var // get wrapped window if using Shadow DOM polyfill
- window = (function () {
- // create a TextNode
- var el = realWindow.document.createTextNode('');
-
- // check if it's wrapped by a polyfill
- if (el.ownerDocument !== realWindow.document
- && typeof realWindow.wrap === 'function'
- && realWindow.wrap(el) === el) {
- // return wrapped window
- return realWindow.wrap(realWindow);
- }
-
- // no Shadow DOM polyfil or native implementation
- return realWindow;
- }()),
-
- document = window.document,
- DocumentFragment = window.DocumentFragment || blank,
- SVGElement = window.SVGElement || blank,
- SVGSVGElement = window.SVGSVGElement || blank,
- SVGElementInstance = window.SVGElementInstance || blank,
- HTMLElement = window.HTMLElement || window.Element,
-
- PointerEvent = (window.PointerEvent || window.MSPointerEvent),
- pEventTypes,
-
- hypot = Math.hypot || function (x, y) { return Math.sqrt(x * x + y * y); },
-
- tmpXY = {}, // reduce object creation in getXY()
-
- documents = [], // all documents being listened to
-
- interactables = [], // all set interactables
- interactions = [], // all interactions
-
- dynamicDrop = false,
-
- // {
- // type: {
- // selectors: ['selector', ...],
- // contexts : [document, ...],
- // listeners: [[listener, useCapture], ...]
- // }
- // }
- delegatedEvents = {},
-
- defaultOptions = {
- base: {
- accept : null,
- actionChecker : null,
- styleCursor : true,
- preventDefault: 'auto',
- origin : { x: 0, y: 0 },
- deltaSource : 'page',
- allowFrom : null,
- ignoreFrom : null,
- _context : document,
- dropChecker : null
- },
-
- drag: {
- enabled: false,
- manualStart: true,
- max: Infinity,
- maxPerElement: 1,
-
- snap: null,
- restrict: null,
- inertia: null,
- autoScroll: null,
-
- axis: 'xy',
- },
-
- drop: {
- enabled: false,
- accept: null,
- overlap: 'pointer'
- },
-
- resize: {
- enabled: false,
- manualStart: false,
- max: Infinity,
- maxPerElement: 1,
-
- snap: null,
- restrict: null,
- inertia: null,
- autoScroll: null,
-
- square: false,
- axis: 'xy',
-
- // use default margin
- margin: NaN,
-
- // object with props left, right, top, bottom which are
- // true/false values to resize when the pointer is over that edge,
- // CSS selectors to match the handles for each direction
- // or the Elements for each handle
- edges: null,
-
- // a value of 'none' will limit the resize rect to a minimum of 0x0
- // 'negate' will alow the rect to have negative width/height
- // 'reposition' will keep the width/height positive by swapping
- // the top and bottom edges and/or swapping the left and right edges
- invert: 'none'
- },
-
- gesture: {
- manualStart: false,
- enabled: false,
- max: Infinity,
- maxPerElement: 1,
-
- restrict: null
- },
-
- perAction: {
- manualStart: false,
- max: Infinity,
- maxPerElement: 1,
-
- snap: {
- enabled : false,
- endOnly : false,
- range : Infinity,
- targets : null,
- offsets : null,
-
- relativePoints: null
- },
-
- restrict: {
- enabled: false,
- endOnly: false
- },
-
- autoScroll: {
- enabled : false,
- container : null, // the item that is scrolled (Window or HTMLElement)
- margin : 60,
- speed : 300 // the scroll speed in pixels per second
- },
-
- inertia: {
- enabled : false,
- resistance : 10, // the lambda in exponential decay
- minSpeed : 100, // target speed must be above this for inertia to start
- endSpeed : 10, // the speed at which inertia is slow enough to stop
- allowResume : true, // allow resuming an action in inertia phase
- zeroResumeDelta : true, // if an action is resumed after launch, set dx/dy to 0
- smoothEndDuration: 300 // animate to snap/restrict endOnly if there's no inertia
- }
- },
-
- _holdDuration: 600
- },
-
- // Things related to autoScroll
- autoScroll = {
- interaction: null,
- i: null, // the handle returned by window.setInterval
- x: 0, y: 0, // Direction each pulse is to scroll in
-
- // scroll the window by the values in scroll.x/y
- scroll: function () {
- var options = autoScroll.interaction.target.options[autoScroll.interaction.prepared.name].autoScroll,
- container = options.container || getWindow(autoScroll.interaction.element),
- now = new Date().getTime(),
- // change in time in seconds
- dt = (now - autoScroll.prevTime) / 1000,
- // displacement
- s = options.speed * dt;
-
- if (s >= 1) {
- if (isWindow(container)) {
- container.scrollBy(autoScroll.x * s, autoScroll.y * s);
- }
- else if (container) {
- container.scrollLeft += autoScroll.x * s;
- container.scrollTop += autoScroll.y * s;
- }
-
- autoScroll.prevTime = now;
- }
-
- if (autoScroll.isScrolling) {
- cancelFrame(autoScroll.i);
- autoScroll.i = reqFrame(autoScroll.scroll);
- }
- },
-
- isScrolling: false,
- prevTime: 0,
-
- start: function (interaction) {
- autoScroll.isScrolling = true;
- cancelFrame(autoScroll.i);
-
- autoScroll.interaction = interaction;
- autoScroll.prevTime = new Date().getTime();
- autoScroll.i = reqFrame(autoScroll.scroll);
- },
-
- stop: function () {
- autoScroll.isScrolling = false;
- cancelFrame(autoScroll.i);
- }
- },
-
- // Does the browser support touch input?
- supportsTouch = (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch),
-
- // Does the browser support PointerEvents
- supportsPointerEvent = !!PointerEvent,
-
- // Less Precision with touch input
- margin = supportsTouch || supportsPointerEvent? 20: 10,
-
- pointerMoveTolerance = 1,
-
- // for ignoring browser's simulated mouse events
- prevTouchTime = 0,
-
- // Allow this many interactions to happen simultaneously
- maxInteractions = Infinity,
-
- // Check if is IE9 or older
- actionCursors = (document.all && !window.atob) ? {
- drag : 'move',
- resizex : 'e-resize',
- resizey : 's-resize',
- resizexy: 'se-resize',
-
- resizetop : 'n-resize',
- resizeleft : 'w-resize',
- resizebottom : 's-resize',
- resizeright : 'e-resize',
- resizetopleft : 'se-resize',
- resizebottomright: 'se-resize',
- resizetopright : 'ne-resize',
- resizebottomleft : 'ne-resize',
-
- gesture : ''
- } : {
- drag : 'move',
- resizex : 'ew-resize',
- resizey : 'ns-resize',
- resizexy: 'nwse-resize',
-
- resizetop : 'ns-resize',
- resizeleft : 'ew-resize',
- resizebottom : 'ns-resize',
- resizeright : 'ew-resize',
- resizetopleft : 'nwse-resize',
- resizebottomright: 'nwse-resize',
- resizetopright : 'nesw-resize',
- resizebottomleft : 'nesw-resize',
-
- gesture : ''
- },
-
- actionIsEnabled = {
- drag : true,
- resize : true,
- gesture: true
- },
-
- // because Webkit and Opera still use 'mousewheel' event type
- wheelEvent = 'onmousewheel' in document? 'mousewheel': 'wheel',
-
- eventTypes = [
- 'dragstart',
- 'dragmove',
- 'draginertiastart',
- 'dragend',
- 'dragenter',
- 'dragleave',
- 'dropactivate',
- 'dropdeactivate',
- 'dropmove',
- 'drop',
- 'resizestart',
- 'resizemove',
- 'resizeinertiastart',
- 'resizeend',
- 'gesturestart',
- 'gesturemove',
- 'gestureinertiastart',
- 'gestureend',
-
- 'down',
- 'move',
- 'up',
- 'cancel',
- 'tap',
- 'doubletap',
- 'hold'
- ],
-
- globalEvents = {},
-
- // Opera Mobile must be handled differently
- isOperaMobile = navigator.appName == 'Opera' &&
- supportsTouch &&
- navigator.userAgent.match('Presto'),
-
- // scrolling doesn't change the result of
- // getBoundingClientRect/getClientRects on iOS <=7 but it does on iOS 8
- isIOS7orLower = (/iP(hone|od|ad)/.test(navigator.platform)
- && /OS [1-7][^\d]/.test(navigator.appVersion)),
-
- // prefix matchesSelector
- prefixedMatchesSelector = 'matches' in Element.prototype?
- 'matches': 'webkitMatchesSelector' in Element.prototype?
- 'webkitMatchesSelector': 'mozMatchesSelector' in Element.prototype?
- 'mozMatchesSelector': 'oMatchesSelector' in Element.prototype?
- 'oMatchesSelector': 'msMatchesSelector',
-
- // will be polyfill function if browser is IE8
- ie8MatchesSelector,
-
- // native requestAnimationFrame or polyfill
- reqFrame = realWindow.requestAnimationFrame,
- cancelFrame = realWindow.cancelAnimationFrame,
-
- // Events wrapper
- events = (function () {
- var useAttachEvent = ('attachEvent' in window) && !('addEventListener' in window),
- addEvent = useAttachEvent? 'attachEvent': 'addEventListener',
- removeEvent = useAttachEvent? 'detachEvent': 'removeEventListener',
- on = useAttachEvent? 'on': '',
-
- elements = [],
- targets = [],
- attachedListeners = [];
-
- function add (element, type, listener, useCapture) {
- var elementIndex = indexOf(elements, element),
- target = targets[elementIndex];
-
- if (!target) {
- target = {
- events: {},
- typeCount: 0
- };
-
- elementIndex = elements.push(element) - 1;
- targets.push(target);
-
- attachedListeners.push((useAttachEvent ? {
- supplied: [],
- wrapped : [],
- useCount: []
- } : null));
- }
-
- if (!target.events[type]) {
- target.events[type] = [];
- target.typeCount++;
- }
-
- if (!contains(target.events[type], listener)) {
- var ret;
-
- if (useAttachEvent) {
- var listeners = attachedListeners[elementIndex],
- listenerIndex = indexOf(listeners.supplied, listener);
-
- var wrapped = listeners.wrapped[listenerIndex] || function (event) {
- if (!event.immediatePropagationStopped) {
- event.target = event.srcElement;
- event.currentTarget = element;
-
- event.preventDefault = event.preventDefault || preventDef;
- event.stopPropagation = event.stopPropagation || stopProp;
- event.stopImmediatePropagation = event.stopImmediatePropagation || stopImmProp;
-
- if (/mouse|click/.test(event.type)) {
- event.pageX = event.clientX + getWindow(element).document.documentElement.scrollLeft;
- event.pageY = event.clientY + getWindow(element).document.documentElement.scrollTop;
- }
-
- listener(event);
- }
- };
-
- ret = element[addEvent](on + type, wrapped, Boolean(useCapture));
-
- if (listenerIndex === -1) {
- listeners.supplied.push(listener);
- listeners.wrapped.push(wrapped);
- listeners.useCount.push(1);
- }
- else {
- listeners.useCount[listenerIndex]++;
- }
- }
- else {
- ret = element[addEvent](type, listener, useCapture || false);
- }
- target.events[type].push(listener);
-
- return ret;
- }
- }
-
- function remove (element, type, listener, useCapture) {
- var i,
- elementIndex = indexOf(elements, element),
- target = targets[elementIndex],
- listeners,
- listenerIndex,
- wrapped = listener;
-
- if (!target || !target.events) {
- return;
- }
-
- if (useAttachEvent) {
- listeners = attachedListeners[elementIndex];
- listenerIndex = indexOf(listeners.supplied, listener);
- wrapped = listeners.wrapped[listenerIndex];
- }
-
- if (type === 'all') {
- for (type in target.events) {
- if (target.events.hasOwnProperty(type)) {
- remove(element, type, 'all');
- }
- }
- return;
- }
-
- if (target.events[type]) {
- var len = target.events[type].length;
-
- if (listener === 'all') {
- for (i = 0; i < len; i++) {
- remove(element, type, target.events[type][i], Boolean(useCapture));
- }
- return;
- } else {
- for (i = 0; i < len; i++) {
- if (target.events[type][i] === listener) {
- element[removeEvent](on + type, wrapped, useCapture || false);
- target.events[type].splice(i, 1);
-
- if (useAttachEvent && listeners) {
- listeners.useCount[listenerIndex]--;
- if (listeners.useCount[listenerIndex] === 0) {
- listeners.supplied.splice(listenerIndex, 1);
- listeners.wrapped.splice(listenerIndex, 1);
- listeners.useCount.splice(listenerIndex, 1);
- }
- }
-
- break;
- }
- }
- }
-
- if (target.events[type] && target.events[type].length === 0) {
- target.events[type] = null;
- target.typeCount--;
- }
- }
-
- if (!target.typeCount) {
- targets.splice(elementIndex, 1);
- elements.splice(elementIndex, 1);
- attachedListeners.splice(elementIndex, 1);
- }
- }
-
- function preventDef () {
- this.returnValue = false;
- }
-
- function stopProp () {
- this.cancelBubble = true;
- }
-
- function stopImmProp () {
- this.cancelBubble = true;
- this.immediatePropagationStopped = true;
- }
-
- return {
- add: add,
- remove: remove,
- useAttachEvent: useAttachEvent,
-
- _elements: elements,
- _targets: targets,
- _attachedListeners: attachedListeners
- };
- }());
-
- function blank () {}
-
- function isElement (o) {
- if (!o || (typeof o !== 'object')) { return false; }
-
- var _window = getWindow(o) || window;
-
- return (/object|function/.test(typeof _window.Element)
- ? o instanceof _window.Element //DOM2
- : o.nodeType === 1 && typeof o.nodeName === "string");
- }
- function isWindow (thing) { return !!(thing && thing.Window) && (thing instanceof thing.Window); }
- function isDocFrag (thing) { return !!thing && thing instanceof DocumentFragment; }
- function isArray (thing) {
- return isObject(thing)
- && (typeof thing.length !== undefined)
- && isFunction(thing.splice);
- }
- function isObject (thing) { return !!thing && (typeof thing === 'object'); }
- function isFunction (thing) { return typeof thing === 'function'; }
- function isNumber (thing) { return typeof thing === 'number' ; }
- function isBool (thing) { return typeof thing === 'boolean' ; }
- function isString (thing) { return typeof thing === 'string' ; }
-
- function trySelector (value) {
- if (!isString(value)) { return false; }
-
- // an exception will be raised if it is invalid
- document.querySelector(value);
- return true;
- }
-
- function extend (dest, source) {
- for (var prop in source) {
- dest[prop] = source[prop];
- }
- return dest;
- }
-
- function copyCoords (dest, src) {
- dest.page = dest.page || {};
- dest.page.x = src.page.x;
- dest.page.y = src.page.y;
-
- dest.client = dest.client || {};
- dest.client.x = src.client.x;
- dest.client.y = src.client.y;
-
- dest.timeStamp = src.timeStamp;
- }
-
- function setEventXY (targetObj, pointer, interaction) {
- if (!pointer) {
- if (interaction.pointerIds.length > 1) {
- pointer = touchAverage(interaction.pointers);
- }
- else {
- pointer = interaction.pointers[0];
- }
- }
-
- getPageXY(pointer, tmpXY, interaction);
- targetObj.page.x = tmpXY.x;
- targetObj.page.y = tmpXY.y;
-
- getClientXY(pointer, tmpXY, interaction);
- targetObj.client.x = tmpXY.x;
- targetObj.client.y = tmpXY.y;
-
- targetObj.timeStamp = new Date().getTime();
- }
-
- function setEventDeltas (targetObj, prev, cur) {
- targetObj.page.x = cur.page.x - prev.page.x;
- targetObj.page.y = cur.page.y - prev.page.y;
- targetObj.client.x = cur.client.x - prev.client.x;
- targetObj.client.y = cur.client.y - prev.client.y;
- targetObj.timeStamp = new Date().getTime() - prev.timeStamp;
-
- // set pointer velocity
- var dt = Math.max(targetObj.timeStamp / 1000, 0.001);
- targetObj.page.speed = hypot(targetObj.page.x, targetObj.page.y) / dt;
- targetObj.page.vx = targetObj.page.x / dt;
- targetObj.page.vy = targetObj.page.y / dt;
-
- targetObj.client.speed = hypot(targetObj.client.x, targetObj.page.y) / dt;
- targetObj.client.vx = targetObj.client.x / dt;
- targetObj.client.vy = targetObj.client.y / dt;
- }
-
- // Get specified X/Y coords for mouse or event.touches[0]
- function getXY (type, pointer, xy) {
- xy = xy || {};
- type = type || 'page';
-
- xy.x = pointer[type + 'X'];
- xy.y = pointer[type + 'Y'];
-
- return xy;
- }
-
- function getPageXY (pointer, page, interaction) {
- page = page || {};
-
- if (pointer instanceof InteractEvent) {
- if (/inertiastart/.test(pointer.type)) {
- interaction = interaction || pointer.interaction;
-
- extend(page, interaction.inertiaStatus.upCoords.page);
-
- page.x += interaction.inertiaStatus.sx;
- page.y += interaction.inertiaStatus.sy;
- }
- else {
- page.x = pointer.pageX;
- page.y = pointer.pageY;
- }
- }
- // Opera Mobile handles the viewport and scrolling oddly
- else if (isOperaMobile) {
- getXY('screen', pointer, page);
-
- page.x += window.scrollX;
- page.y += window.scrollY;
- }
- else {
- getXY('page', pointer, page);
- }
-
- return page;
- }
-
- function getClientXY (pointer, client, interaction) {
- client = client || {};
-
- if (pointer instanceof InteractEvent) {
- if (/inertiastart/.test(pointer.type)) {
- extend(client, interaction.inertiaStatus.upCoords.client);
-
- client.x += interaction.inertiaStatus.sx;
- client.y += interaction.inertiaStatus.sy;
- }
- else {
- client.x = pointer.clientX;
- client.y = pointer.clientY;
- }
- }
- else {
- // Opera Mobile handles the viewport and scrolling oddly
- getXY(isOperaMobile? 'screen': 'client', pointer, client);
- }
-
- return client;
- }
-
- function getScrollXY (win) {
- win = win || window;
- return {
- x: win.scrollX || win.document.documentElement.scrollLeft,
- y: win.scrollY || win.document.documentElement.scrollTop
- };
- }
-
- function getPointerId (pointer) {
- return isNumber(pointer.pointerId)? pointer.pointerId : pointer.identifier;
- }
-
- function getActualElement (element) {
- return (element instanceof SVGElementInstance
- ? element.correspondingUseElement
- : element);
- }
-
- function getWindow (node) {
- if (isWindow(node)) {
- return node;
- }
-
- var rootNode = (node.ownerDocument || node);
-
- return rootNode.defaultView || rootNode.parentWindow || window;
- }
-
- function getElementRect (element) {
- var scroll = isIOS7orLower
- ? { x: 0, y: 0 }
- : getScrollXY(getWindow(element)),
- clientRect = (element instanceof SVGElement)?
- element.getBoundingClientRect():
- element.getClientRects()[0];
-
- return clientRect && {
- left : clientRect.left + scroll.x,
- right : clientRect.right + scroll.x,
- top : clientRect.top + scroll.y,
- bottom: clientRect.bottom + scroll.y,
- width : clientRect.width || clientRect.right - clientRect.left,
- height: clientRect.heigh || clientRect.bottom - clientRect.top
- };
- }
-
- function getTouchPair (event) {
- var touches = [];
-
- // array of touches is supplied
- if (isArray(event)) {
- touches[0] = event[0];
- touches[1] = event[1];
- }
- // an event
- else {
- if (event.type === 'touchend') {
- if (event.touches.length === 1) {
- touches[0] = event.touches[0];
- touches[1] = event.changedTouches[0];
- }
- else if (event.touches.length === 0) {
- touches[0] = event.changedTouches[0];
- touches[1] = event.changedTouches[1];
- }
- }
- else {
- touches[0] = event.touches[0];
- touches[1] = event.touches[1];
- }
- }
-
- return touches;
- }
-
- function touchAverage (event) {
- var touches = getTouchPair(event);
-
- return {
- pageX: (touches[0].pageX + touches[1].pageX) / 2,
- pageY: (touches[0].pageY + touches[1].pageY) / 2,
- clientX: (touches[0].clientX + touches[1].clientX) / 2,
- clientY: (touches[0].clientY + touches[1].clientY) / 2
- };
- }
-
- function touchBBox (event) {
- if (!event.length && !(event.touches && event.touches.length > 1)) {
- return;
- }
-
- var touches = getTouchPair(event),
- minX = Math.min(touches[0].pageX, touches[1].pageX),
- minY = Math.min(touches[0].pageY, touches[1].pageY),
- maxX = Math.max(touches[0].pageX, touches[1].pageX),
- maxY = Math.max(touches[0].pageY, touches[1].pageY);
-
- return {
- x: minX,
- y: minY,
- left: minX,
- top: minY,
- width: maxX - minX,
- height: maxY - minY
- };
- }
-
- function touchDistance (event, deltaSource) {
- deltaSource = deltaSource || defaultOptions.deltaSource;
-
- var sourceX = deltaSource + 'X',
- sourceY = deltaSource + 'Y',
- touches = getTouchPair(event);
-
-
- var dx = touches[0][sourceX] - touches[1][sourceX],
- dy = touches[0][sourceY] - touches[1][sourceY];
-
- return hypot(dx, dy);
- }
-
- function touchAngle (event, prevAngle, deltaSource) {
- deltaSource = deltaSource || defaultOptions.deltaSource;
-
- var sourceX = deltaSource + 'X',
- sourceY = deltaSource + 'Y',
- touches = getTouchPair(event),
- dx = touches[0][sourceX] - touches[1][sourceX],
- dy = touches[0][sourceY] - touches[1][sourceY],
- angle = 180 * Math.atan(dy / dx) / Math.PI;
-
- if (isNumber(prevAngle)) {
- var dr = angle - prevAngle,
- drClamped = dr % 360;
-
- if (drClamped > 315) {
- angle -= 360 + (angle / 360)|0 * 360;
- }
- else if (drClamped > 135) {
- angle -= 180 + (angle / 360)|0 * 360;
- }
- else if (drClamped < -315) {
- angle += 360 + (angle / 360)|0 * 360;
- }
- else if (drClamped < -135) {
- angle += 180 + (angle / 360)|0 * 360;
- }
- }
-
- return angle;
- }
-
- function getOriginXY (interactable, element) {
- var origin = interactable
- ? interactable.options.origin
- : defaultOptions.origin;
-
- if (origin === 'parent') {
- origin = parentElement(element);
- }
- else if (origin === 'self') {
- origin = interactable.getRect(element);
- }
- else if (trySelector(origin)) {
- origin = closest(element, origin) || { x: 0, y: 0 };
- }
-
- if (isFunction(origin)) {
- origin = origin(interactable && element);
- }
-
- if (isElement(origin)) {
- origin = getElementRect(origin);
- }
-
- origin.x = ('x' in origin)? origin.x : origin.left;
- origin.y = ('y' in origin)? origin.y : origin.top;
-
- return origin;
- }
-
- // http://stackoverflow.com/a/5634528/2280888
- function _getQBezierValue(t, p1, p2, p3) {
- var iT = 1 - t;
- return iT * iT * p1 + 2 * iT * t * p2 + t * t * p3;
- }
-
- function getQuadraticCurvePoint(startX, startY, cpX, cpY, endX, endY, position) {
- return {
- x: _getQBezierValue(position, startX, cpX, endX),
- y: _getQBezierValue(position, startY, cpY, endY)
- };
- }
-
- // http://gizma.com/easing/
- function easeOutQuad (t, b, c, d) {
- t /= d;
- return -c * t*(t-2) + b;
- }
-
- function nodeContains (parent, child) {
- while (child) {
- if (child === parent) {
- return true;
- }
-
- child = child.parentNode;
- }
-
- return false;
- }
-
- function closest (child, selector) {
- var parent = parentElement(child);
-
- while (isElement(parent)) {
- if (matchesSelector(parent, selector)) { return parent; }
-
- parent = parentElement(parent);
- }
-
- return null;
- }
-
- function parentElement (node) {
- var parent = node.parentNode;
-
- if (isDocFrag(parent)) {
- // skip past #shado-root fragments
- while ((parent = parent.host) && isDocFrag(parent)) {}
-
- return parent;
- }
-
- return parent;
- }
-
- function inContext (interactable, element) {
- return interactable._context === element.ownerDocument
- || nodeContains(interactable._context, element);
- }
-
- function testIgnore (interactable, interactableElement, element) {
- var ignoreFrom = interactable.options.ignoreFrom;
-
- if (!ignoreFrom || !isElement(element)) { return false; }
-
- if (isString(ignoreFrom)) {
- return matchesUpTo(element, ignoreFrom, interactableElement);
- }
- else if (isElement(ignoreFrom)) {
- return nodeContains(ignoreFrom, element);
- }
-
- return false;
- }
-
- function testAllow (interactable, interactableElement, element) {
- var allowFrom = interactable.options.allowFrom;
-
- if (!allowFrom) { return true; }
-
- if (!isElement(element)) { return false; }
-
- if (isString(allowFrom)) {
- return matchesUpTo(element, allowFrom, interactableElement);
- }
- else if (isElement(allowFrom)) {
- return nodeContains(allowFrom, element);
- }
-
- return false;
- }
-
- function checkAxis (axis, interactable) {
- if (!interactable) { return false; }
-
- var thisAxis = interactable.options.drag.axis;
-
- return (axis === 'xy' || thisAxis === 'xy' || thisAxis === axis);
- }
-
- function checkSnap (interactable, action) {
- var options = interactable.options;
-
- if (/^resize/.test(action)) {
- action = 'resize';
- }
-
- return options[action].snap && options[action].snap.enabled;
- }
-
- function checkRestrict (interactable, action) {
- var options = interactable.options;
-
- if (/^resize/.test(action)) {
- action = 'resize';
- }
-
- return options[action].restrict && options[action].restrict.enabled;
- }
-
- function checkAutoScroll (interactable, action) {
- var options = interactable.options;
-
- if (/^resize/.test(action)) {
- action = 'resize';
- }
-
- return options[action].autoScroll && options[action].autoScroll.enabled;
- }
-
- function withinInteractionLimit (interactable, element, action) {
- var options = interactable.options,
- maxActions = options[action.name].max,
- maxPerElement = options[action.name].maxPerElement,
- activeInteractions = 0,
- targetCount = 0,
- targetElementCount = 0;
-
- for (var i = 0, len = interactions.length; i < len; i++) {
- var interaction = interactions[i],
- otherAction = interaction.prepared.name,
- active = interaction.interacting();
-
- if (!active) { continue; }
-
- activeInteractions++;
-
- if (activeInteractions >= maxInteractions) {
- return false;
- }
-
- if (interaction.target !== interactable) { continue; }
-
- targetCount += (otherAction === action.name)|0;
-
- if (targetCount >= maxActions) {
- return false;
- }
-
- if (interaction.element === element) {
- targetElementCount++;
-
- if (otherAction !== action.name || targetElementCount >= maxPerElement) {
- return false;
- }
- }
- }
-
- return maxInteractions > 0;
- }
-
- // Test for the element that's "above" all other qualifiers
- function indexOfDeepestElement (elements) {
- var dropzone,
- deepestZone = elements[0],
- index = deepestZone? 0: -1,
- parent,
- deepestZoneParents = [],
- dropzoneParents = [],
- child,
- i,
- n;
-
- for (i = 1; i < elements.length; i++) {
- dropzone = elements[i];
-
- // an element might belong to multiple selector dropzones
- if (!dropzone || dropzone === deepestZone) {
- continue;
- }
-
- if (!deepestZone) {
- deepestZone = dropzone;
- index = i;
- continue;
- }
-
- // check if the deepest or current are document.documentElement or document.rootElement
- // - if the current dropzone is, do nothing and continue
- if (dropzone.parentNode === dropzone.ownerDocument) {
- continue;
- }
- // - if deepest is, update with the current dropzone and continue to next
- else if (deepestZone.parentNode === dropzone.ownerDocument) {
- deepestZone = dropzone;
- index = i;
- continue;
- }
-
- if (!deepestZoneParents.length) {
- parent = deepestZone;
- while (parent.parentNode && parent.parentNode !== parent.ownerDocument) {
- deepestZoneParents.unshift(parent);
- parent = parent.parentNode;
- }
- }
-
- // if this element is an svg element and the current deepest is
- // an HTMLElement
- if (deepestZone instanceof HTMLElement
- && dropzone instanceof SVGElement
- && !(dropzone instanceof SVGSVGElement)) {
-
- if (dropzone === deepestZone.parentNode) {
- continue;
- }
-
- parent = dropzone.ownerSVGElement;
- }
- else {
- parent = dropzone;
- }
-
- dropzoneParents = [];
-
- while (parent.parentNode !== parent.ownerDocument) {
- dropzoneParents.unshift(parent);
- parent = parent.parentNode;
- }
-
- n = 0;
-
- // get (position of last common ancestor) + 1
- while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) {
- n++;
- }
-
- var parents = [
- dropzoneParents[n - 1],
- dropzoneParents[n],
- deepestZoneParents[n]
- ];
-
- child = parents[0].lastChild;
-
- while (child) {
- if (child === parents[1]) {
- deepestZone = dropzone;
- index = i;
- deepestZoneParents = [];
-
- break;
- }
- else if (child === parents[2]) {
- break;
- }
-
- child = child.previousSibling;
- }
- }
-
- return index;
- }
-
- function Interaction () {
- this.target = null; // current interactable being interacted with
- this.element = null; // the target element of the interactable
- this.dropTarget = null; // the dropzone a drag target might be dropped into
- this.dropElement = null; // the element at the time of checking
- this.prevDropTarget = null; // the dropzone that was recently dragged away from
- this.prevDropElement = null; // the element at the time of checking
-
- this.prepared = { // action that's ready to be fired on next move event
- name : null,
- axis : null,
- edges: null
- };
-
- this.matches = []; // all selectors that are matched by target element
- this.matchElements = []; // corresponding elements
-
- this.inertiaStatus = {
- active : false,
- smoothEnd : false,
-
- startEvent: null,
- upCoords: {},
-
- xe: 0, ye: 0,
- sx: 0, sy: 0,
-
- t0: 0,
- vx0: 0, vys: 0,
- duration: 0,
-
- resumeDx: 0,
- resumeDy: 0,
-
- lambda_v0: 0,
- one_ve_v0: 0,
- i : null
- };
-
- if (isFunction(Function.prototype.bind)) {
- this.boundInertiaFrame = this.inertiaFrame.bind(this);
- this.boundSmoothEndFrame = this.smoothEndFrame.bind(this);
- }
- else {
- var that = this;
-
- this.boundInertiaFrame = function () { return that.inertiaFrame(); };
- this.boundSmoothEndFrame = function () { return that.smoothEndFrame(); };
- }
-
- this.activeDrops = {
- dropzones: [], // the dropzones that are mentioned below
- elements : [], // elements of dropzones that accept the target draggable
- rects : [] // the rects of the elements mentioned above
- };
-
- // keep track of added pointers
- this.pointers = [];
- this.pointerIds = [];
- this.downTargets = [];
- this.downTimes = [];
- this.holdTimers = [];
-
- // Previous native pointer move event coordinates
- this.prevCoords = {
- page : { x: 0, y: 0 },
- client : { x: 0, y: 0 },
- timeStamp: 0
- };
- // current native pointer move event coordinates
- this.curCoords = {
- page : { x: 0, y: 0 },
- client : { x: 0, y: 0 },
- timeStamp: 0
- };
-
- // Starting InteractEvent pointer coordinates
- this.startCoords = {
- page : { x: 0, y: 0 },
- client : { x: 0, y: 0 },
- timeStamp: 0
- };
-
- // Change in coordinates and time of the pointer
- this.pointerDelta = {
- page : { x: 0, y: 0, vx: 0, vy: 0, speed: 0 },
- client : { x: 0, y: 0, vx: 0, vy: 0, speed: 0 },
- timeStamp: 0
- };
-
- this.downEvent = null; // pointerdown/mousedown/touchstart event
- this.downPointer = {};
-
- this._eventTarget = null;
- this._curEventTarget = null;
-
- this.prevEvent = null; // previous action event
- this.tapTime = 0; // time of the most recent tap event
- this.prevTap = null;
-
- this.startOffset = { left: 0, right: 0, top: 0, bottom: 0 };
- this.restrictOffset = { left: 0, right: 0, top: 0, bottom: 0 };
- this.snapOffsets = [];
-
- this.gesture = {
- start: { x: 0, y: 0 },
-
- startDistance: 0, // distance between two touches of touchStart
- prevDistance : 0,
- distance : 0,
-
- scale: 1, // gesture.distance / gesture.startDistance
-
- startAngle: 0, // angle of line joining two touches
- prevAngle : 0 // angle of the previous gesture event
- };
-
- this.snapStatus = {
- x : 0, y : 0,
- dx : 0, dy : 0,
- realX : 0, realY : 0,
- snappedX: 0, snappedY: 0,
- targets : [],
- locked : false,
- changed : false
- };
-
- this.restrictStatus = {
- dx : 0, dy : 0,
- restrictedX: 0, restrictedY: 0,
- snap : null,
- restricted : false,
- changed : false
- };
-
- this.restrictStatus.snap = this.snapStatus;
-
- this.pointerIsDown = false;
- this.pointerWasMoved = false;
- this.gesturing = false;
- this.dragging = false;
- this.resizing = false;
- this.resizeAxes = 'xy';
-
- this.mouse = false;
-
- interactions.push(this);
- }
-
- Interaction.prototype = {
- getPageXY : function (pointer, xy) { return getPageXY(pointer, xy, this); },
- getClientXY: function (pointer, xy) { return getClientXY(pointer, xy, this); },
- setEventXY : function (target, ptr) { return setEventXY(target, ptr, this); },
-
- pointerOver: function (pointer, event, eventTarget) {
- if (this.prepared.name || !this.mouse) { return; }
-
- var curMatches = [],
- curMatchElements = [],
- prevTargetElement = this.element;
-
- this.addPointer(pointer);
-
- if (this.target
- && (testIgnore(this.target, this.element, eventTarget)
- || !testAllow(this.target, this.element, eventTarget))) {
- // if the eventTarget should be ignored or shouldn't be allowed
- // clear the previous target
- this.target = null;
- this.element = null;
- this.matches = [];
- this.matchElements = [];
- }
-
- var elementInteractable = interactables.get(eventTarget),
- elementAction = (elementInteractable
- && !testIgnore(elementInteractable, eventTarget, eventTarget)
- && testAllow(elementInteractable, eventTarget, eventTarget)
- && validateAction(
- elementInteractable.getAction(pointer, this, eventTarget),
- elementInteractable));
-
- if (elementAction && !withinInteractionLimit(elementInteractable, eventTarget, elementAction)) {
- elementAction = null;
- }
-
- function pushCurMatches (interactable, selector) {
- if (interactable
- && inContext(interactable, eventTarget)
- && !testIgnore(interactable, eventTarget, eventTarget)
- && testAllow(interactable, eventTarget, eventTarget)
- && matchesSelector(eventTarget, selector)) {
-
- curMatches.push(interactable);
- curMatchElements.push(eventTarget);
- }
- }
-
- if (elementAction) {
- this.target = elementInteractable;
- this.element = eventTarget;
- this.matches = [];
- this.matchElements = [];
- }
- else {
- interactables.forEachSelector(pushCurMatches);
-
- if (this.validateSelector(pointer, curMatches, curMatchElements)) {
- this.matches = curMatches;
- this.matchElements = curMatchElements;
-
- this.pointerHover(pointer, event, this.matches, this.matchElements);
- events.add(eventTarget,
- PointerEvent? pEventTypes.move : 'mousemove',
- listeners.pointerHover);
- }
- else if (this.target) {
- if (nodeContains(prevTargetElement, eventTarget)) {
- this.pointerHover(pointer, event, this.matches, this.matchElements);
- events.add(this.element,
- PointerEvent? pEventTypes.move : 'mousemove',
- listeners.pointerHover);
- }
- else {
- this.target = null;
- this.element = null;
- this.matches = [];
- this.matchElements = [];
- }
- }
- }
- },
-
- // Check what action would be performed on pointerMove target if a mouse
- // button were pressed and change the cursor accordingly
- pointerHover: function (pointer, event, eventTarget, curEventTarget, matches, matchElements) {
- var target = this.target;
-
- if (!this.prepared.name && this.mouse) {
-
- var action;
-
- // update pointer coords for defaultActionChecker to use
- this.setEventXY(this.curCoords, pointer);
-
- if (matches) {
- action = this.validateSelector(pointer, matches, matchElements);
- }
- else if (target) {
- action = validateAction(target.getAction(this.pointers[0], this, this.element), this.target);
- }
-
- if (target && target.options.styleCursor) {
- if (action) {
- target._doc.documentElement.style.cursor = getActionCursor(action);
- }
- else {
- target._doc.documentElement.style.cursor = '';
- }
- }
- }
- else if (this.prepared.name) {
- this.checkAndPreventDefault(event, target, this.element);
- }
- },
-
- pointerOut: function (pointer, event, eventTarget) {
- if (this.prepared.name) { return; }
-
- // Remove temporary event listeners for selector Interactables
- if (!interactables.get(eventTarget)) {
- events.remove(eventTarget,
- PointerEvent? pEventTypes.move : 'mousemove',
- listeners.pointerHover);
- }
-
- if (this.target && this.target.options.styleCursor && !this.interacting()) {
- this.target._doc.documentElement.style.cursor = '';
- }
- },
-
- selectorDown: function (pointer, event, eventTarget, curEventTarget) {
- var that = this,
- // copy event to be used in timeout for IE8
- eventCopy = events.useAttachEvent? extend({}, event) : event,
- element = eventTarget,
- pointerIndex = this.addPointer(pointer),
- action;
-
- this.holdTimers[pointerIndex] = setTimeout(function () {
- that.pointerHold(events.useAttachEvent? eventCopy : pointer, eventCopy, eventTarget, curEventTarget);
- }, defaultOptions._holdDuration);
-
- this.pointerIsDown = true;
-
- // Check if the down event hits the current inertia target
- if (this.inertiaStatus.active && this.target.selector) {
- // climb up the DOM tree from the event target
- while (isElement(element)) {
-
- // if this element is the current inertia target element
- if (element === this.element
- // and the prospective action is the same as the ongoing one
- && validateAction(this.target.getAction(pointer, this, this.element), this.target).name === this.prepared.name) {
-
- // stop inertia so that the next move will be a normal one
- cancelFrame(this.inertiaStatus.i);
- this.inertiaStatus.active = false;
-
- this.collectEventTargets(pointer, event, eventTarget, 'down');
- return;
- }
- element = parentElement(element);
- }
- }
-
- // do nothing if interacting
- if (this.interacting()) {
- this.collectEventTargets(pointer, event, eventTarget, 'down');
- return;
- }
-
- function pushMatches (interactable, selector, context) {
- var elements = ie8MatchesSelector
- ? context.querySelectorAll(selector)
- : undefined;
-
- if (inContext(interactable, element)
- && !testIgnore(interactable, element, eventTarget)
- && testAllow(interactable, element, eventTarget)
- && matchesSelector(element, selector, elements)) {
-
- that.matches.push(interactable);
- that.matchElements.push(element);
- }
- }
-
- // update pointer coords for defaultActionChecker to use
- this.setEventXY(this.curCoords, pointer);
-
- while (isElement(element) && !action) {
- this.matches = [];
- this.matchElements = [];
-
- interactables.forEachSelector(pushMatches);
-
- action = this.validateSelector(pointer, this.matches, this.matchElements);
- element = parentElement(element);
- }
-
- if (action) {
- this.prepared.name = action.name;
- this.prepared.axis = action.axis;
- this.prepared.edges = action.edges;
-
- this.collectEventTargets(pointer, event, eventTarget, 'down');
-
- return this.pointerDown(pointer, event, eventTarget, curEventTarget, action);
- }
- else {
- // do these now since pointerDown isn't being called from here
- this.downTimes[pointerIndex] = new Date().getTime();
- this.downTargets[pointerIndex] = eventTarget;
- this.downEvent = event;
- extend(this.downPointer, pointer);
-
- copyCoords(this.prevCoords, this.curCoords);
- this.pointerWasMoved = false;
- }
-
- this.collectEventTargets(pointer, event, eventTarget, 'down');
- },
-
- // Determine action to be performed on next pointerMove and add appropriate
- // style and event Listeners
- pointerDown: function (pointer, event, eventTarget, curEventTarget, forceAction) {
- if (!forceAction && !this.inertiaStatus.active && this.pointerWasMoved && this.prepared.name) {
- this.checkAndPreventDefault(event, this.target, this.element);
-
- return;
- }
-
- this.pointerIsDown = true;
-
- var pointerIndex = this.addPointer(pointer),
- action;
-
- // If it is the second touch of a multi-touch gesture, keep the target
- // the same if a target was set by the first touch
- // Otherwise, set the target if there is no action prepared
- if ((this.pointerIds.length < 2 && !this.target) || !this.prepared.name) {
-
- var interactable = interactables.get(curEventTarget);
-
- if (interactable
- && !testIgnore(interactable, curEventTarget, eventTarget)
- && testAllow(interactable, curEventTarget, eventTarget)
- && (action = validateAction(forceAction || interactable.getAction(pointer, this, curEventTarget), interactable, eventTarget))
- && withinInteractionLimit(interactable, curEventTarget, action)) {
- this.target = interactable;
- this.element = curEventTarget;
- }
- }
-
- var target = this.target,
- options = target && target.options;
-
- if (target && (forceAction || !this.prepared.name)) {
- action = action || validateAction(forceAction || target.getAction(pointer, this, curEventTarget), target, this.element);
-
- this.setEventXY(this.startCoords);
-
- if (!action) { return; }
-
- if (options.styleCursor) {
- target._doc.documentElement.style.cursor = getActionCursor(action);
- }
-
- this.resizeAxes = action.name === 'resize'? action.axis : null;
-
- if (action === 'gesture' && this.pointerIds.length < 2) {
- action = null;
- }
-
- this.prepared.name = action.name;
- this.prepared.axis = action.axis;
- this.prepared.edges = action.edges;
-
- this.snapStatus.snappedX = this.snapStatus.snappedY =
- this.restrictStatus.restrictedX = this.restrictStatus.restrictedY = NaN;
-
- this.downTimes[pointerIndex] = new Date().getTime();
- this.downTargets[pointerIndex] = eventTarget;
- this.downEvent = event;
- extend(this.downPointer, pointer);
-
- this.setEventXY(this.prevCoords);
- this.pointerWasMoved = false;
-
- this.checkAndPreventDefault(event, target, this.element);
- }
- // if inertia is active try to resume action
- else if (this.inertiaStatus.active
- && curEventTarget === this.element
- && validateAction(target.getAction(pointer, this, this.element), target).name === this.prepared.name) {
-
- cancelFrame(this.inertiaStatus.i);
- this.inertiaStatus.active = false;
-
- this.checkAndPreventDefault(event, target, this.element);
- }
- },
-
- setModifications: function (coords, preEnd) {
- var target = this.target,
- shouldMove = true,
- shouldSnap = checkSnap(target, this.prepared.name) && (!target.options[this.prepared.name].snap.endOnly || preEnd),
- shouldRestrict = checkRestrict(target, this.prepared.name) && (!target.options[this.prepared.name].restrict.endOnly || preEnd);
-
- if (shouldSnap ) { this.setSnapping (coords); } else { this.snapStatus .locked = false; }
- if (shouldRestrict) { this.setRestriction(coords); } else { this.restrictStatus.restricted = false; }
-
- if (shouldSnap && this.snapStatus.locked && !this.snapStatus.changed) {
- shouldMove = shouldRestrict && this.restrictStatus.restricted && this.restrictStatus.changed;
- }
- else if (shouldRestrict && this.restrictStatus.restricted && !this.restrictStatus.changed) {
- shouldMove = false;
- }
-
- return shouldMove;
- },
-
- setStartOffsets: function (action, interactable, element) {
- var rect = interactable.getRect(element),
- origin = getOriginXY(interactable, element),
- snap = interactable.options[this.prepared.name].snap,
- restrict = interactable.options[this.prepared.name].restrict,
- width, height;
-
- if (rect) {
- this.startOffset.left = this.startCoords.page.x - rect.left;
- this.startOffset.top = this.startCoords.page.y - rect.top;
-
- this.startOffset.right = rect.right - this.startCoords.page.x;
- this.startOffset.bottom = rect.bottom - this.startCoords.page.y;
-
- if ('width' in rect) { width = rect.width; }
- else { width = rect.right - rect.left; }
- if ('height' in rect) { height = rect.height; }
- else { height = rect.bottom - rect.top; }
- }
- else {
- this.startOffset.left = this.startOffset.top = this.startOffset.right = this.startOffset.bottom = 0;
- }
-
- this.snapOffsets.splice(0);
-
- var snapOffset = snap && snap.offset === 'startCoords'
- ? {
- x: this.startCoords.page.x - origin.x,
- y: this.startCoords.page.y - origin.y
- }
- : snap && snap.offset || { x: 0, y: 0 };
-
- if (rect && snap && snap.relativePoints && snap.relativePoints.length) {
- for (var i = 0; i < snap.relativePoints.length; i++) {
- this.snapOffsets.push({
- x: this.startOffset.left - (width * snap.relativePoints[i].x) + snapOffset.x,
- y: this.startOffset.top - (height * snap.relativePoints[i].y) + snapOffset.y
- });
- }
- }
- else {
- this.snapOffsets.push(snapOffset);
- }
-
- if (rect && restrict.elementRect) {
- this.restrictOffset.left = this.startOffset.left - (width * restrict.elementRect.left);
- this.restrictOffset.top = this.startOffset.top - (height * restrict.elementRect.top);
-
- this.restrictOffset.right = this.startOffset.right - (width * (1 - restrict.elementRect.right));
- this.restrictOffset.bottom = this.startOffset.bottom - (height * (1 - restrict.elementRect.bottom));
- }
- else {
- this.restrictOffset.left = this.restrictOffset.top = this.restrictOffset.right = this.restrictOffset.bottom = 0;
- }
- },
-
- /*\
- * Interaction.start
- [ method ]
- *
- * Start an action with the given Interactable and Element as tartgets. The
- * action must be enabled for the target Interactable and an appropriate number
- * of pointers must be held down – 1 for drag/resize, 2 for gesture.
- *
- * Use it with `interactable.able({ manualStart: false })` to always
- * [start actions manually](https://github.com/taye/interact.js/issues/114)
- *
- - action (object) The action to be performed - drag, resize, etc.
- - interactable (Interactable) The Interactable to target
- - element (Element) The DOM Element to target
- = (object) interact
- **
- | interact(target)
- | .draggable({
- | // disable the default drag start by down->move
- | manualStart: true
- | })
- | // start dragging after the user holds the pointer down
- | .on('hold', function (event) {
- | var interaction = event.interaction;
- |
- | if (!interaction.interacting()) {
- | interaction.start({ name: 'drag' },
- | event.interactable,
- | event.currentTarget);
- | }
- | });
- \*/
- start: function (action, interactable, element) {
- if (this.interacting()
- || !this.pointerIsDown
- || this.pointerIds.length < (action.name === 'gesture'? 2 : 1)) {
- return;
- }
-
- // if this interaction had been removed after stopping
- // add it back
- if (indexOf(interactions, this) === -1) {
- interactions.push(this);
- }
-
- this.prepared.name = action.name;
- this.prepared.axis = action.axis;
- this.prepared.edges = action.edges;
- this.target = interactable;
- this.element = element;
-
- this.setEventXY(this.startCoords);
- this.setStartOffsets(action.name, interactable, element);
- this.setModifications(this.startCoords.page);
-
- this.prevEvent = this[this.prepared.name + 'Start'](this.downEvent);
- },
-
- pointerMove: function (pointer, event, eventTarget, curEventTarget, preEnd) {
- this.recordPointer(pointer);
-
- this.setEventXY(this.curCoords, (pointer instanceof InteractEvent)
- ? this.inertiaStatus.startEvent
- : undefined);
-
- var duplicateMove = (this.curCoords.page.x === this.prevCoords.page.x
- && this.curCoords.page.y === this.prevCoords.page.y
- && this.curCoords.client.x === this.prevCoords.client.x
- && this.curCoords.client.y === this.prevCoords.client.y);
-
- var dx, dy,
- pointerIndex = this.mouse? 0 : indexOf(this.pointerIds, getPointerId(pointer));
-
- // register movement greater than pointerMoveTolerance
- if (this.pointerIsDown && !this.pointerWasMoved) {
- dx = this.curCoords.client.x - this.startCoords.client.x;
- dy = this.curCoords.client.y - this.startCoords.client.y;
-
- this.pointerWasMoved = hypot(dx, dy) > pointerMoveTolerance;
- }
-
- if (!duplicateMove && (!this.pointerIsDown || this.pointerWasMoved)) {
- if (this.pointerIsDown) {
- clearTimeout(this.holdTimers[pointerIndex]);
- }
-
- this.collectEventTargets(pointer, event, eventTarget, 'move');
- }
-
- if (!this.pointerIsDown) { return; }
-
- if (duplicateMove && this.pointerWasMoved && !preEnd) {
- this.checkAndPreventDefault(event, this.target, this.element);
- return;
- }
-
- // set pointer coordinate, time changes and speeds
- setEventDeltas(this.pointerDelta, this.prevCoords, this.curCoords);
-
- if (!this.prepared.name) { return; }
-
- if (this.pointerWasMoved
- // ignore movement while inertia is active
- && (!this.inertiaStatus.active || (pointer instanceof InteractEvent && /inertiastart/.test(pointer.type)))) {
-
- // if just starting an action, calculate the pointer speed now
- if (!this.interacting()) {
- setEventDeltas(this.pointerDelta, this.prevCoords, this.curCoords);
-
- // check if a drag is in the correct axis
- if (this.prepared.name === 'drag') {
- var absX = Math.abs(dx),
- absY = Math.abs(dy),
- targetAxis = this.target.options.drag.axis,
- axis = (absX > absY ? 'x' : absX < absY ? 'y' : 'xy');
-
- // if the movement isn't in the axis of the interactable
- if (axis !== 'xy' && targetAxis !== 'xy' && targetAxis !== axis) {
- // cancel the prepared action
- this.prepared.name = null;
-
- // then try to get a drag from another ineractable
-
- var element = eventTarget;
-
- // check element interactables
- while (isElement(element)) {
- var elementInteractable = interactables.get(element);
-
- if (elementInteractable
- && elementInteractable !== this.target
- && !elementInteractable.options.drag.manualStart
- && elementInteractable.getAction(this.downPointer, this, element).name === 'drag'
- && checkAxis(axis, elementInteractable)) {
-
- this.prepared.name = 'drag';
- this.target = elementInteractable;
- this.element = element;
- break;
- }
-
- element = parentElement(element);
- }
-
- // if there's no drag from element interactables,
- // check the selector interactables
- if (!this.prepared.name) {
- var thisInteraction = this;
-
- var getDraggable = function (interactable, selector, context) {
- var elements = ie8MatchesSelector
- ? context.querySelectorAll(selector)
- : undefined;
-
- if (interactable === thisInteraction.target) { return; }
-
- if (inContext(interactable, eventTarget)
- && !interactable.options.drag.manualStart
- && !testIgnore(interactable, element, eventTarget)
- && testAllow(interactable, element, eventTarget)
- && matchesSelector(element, selector, elements)
- && interactable.getAction(thisInteraction.downPointer, thisInteraction, element).name === 'drag'
- && checkAxis(axis, interactable)
- && withinInteractionLimit(interactable, element, 'drag')) {
-
- return interactable;
- }
- };
-
- element = eventTarget;
-
- while (isElement(element)) {
- var selectorInteractable = interactables.forEachSelector(getDraggable);
-
- if (selectorInteractable) {
- this.prepared.name = 'drag';
- this.target = selectorInteractable;
- this.element = element;
- break;
- }
-
- element = parentElement(element);
- }
- }
- }
- }
- }
-
- var starting = !!this.prepared.name && !this.interacting();
-
- if (starting
- && (this.target.options[this.prepared.name].manualStart
- || !withinInteractionLimit(this.target, this.element, this.prepared))) {
- this.stop();
- return;
- }
-
- if (this.prepared.name && this.target) {
- if (starting) {
- this.start(this.prepared, this.target, this.element);
- }
-
- var shouldMove = this.setModifications(this.curCoords.page, preEnd);
-
- // move if snapping or restriction doesn't prevent it
- if (shouldMove || starting) {
- this.prevEvent = this[this.prepared.name + 'Move'](event);
- }
-
- this.checkAndPreventDefault(event, this.target, this.element);
- }
- }
-
- copyCoords(this.prevCoords, this.curCoords);
-
- if (this.dragging || this.resizing) {
- this.autoScrollMove(pointer);
- }
- },
-
- dragStart: function (event) {
- var dragEvent = new InteractEvent(this, event, 'drag', 'start', this.element);
-
- this.dragging = true;
- this.target.fire(dragEvent);
-
- // reset active dropzones
- this.activeDrops.dropzones = [];
- this.activeDrops.elements = [];
- this.activeDrops.rects = [];
-
- if (!this.dynamicDrop) {
- this.setActiveDrops(this.element);
- }
-
- var dropEvents = this.getDropEvents(event, dragEvent);
-
- if (dropEvents.activate) {
- this.fireActiveDrops(dropEvents.activate);
- }
-
- return dragEvent;
- },
-
- dragMove: function (event) {
- var target = this.target,
- dragEvent = new InteractEvent(this, event, 'drag', 'move', this.element),
- draggableElement = this.element,
- drop = this.getDrop(dragEvent, draggableElement);
-
- this.dropTarget = drop.dropzone;
- this.dropElement = drop.element;
-
- var dropEvents = this.getDropEvents(event, dragEvent);
-
- target.fire(dragEvent);
-
- if (dropEvents.leave) { this.prevDropTarget.fire(dropEvents.leave); }
- if (dropEvents.enter) { this.dropTarget.fire(dropEvents.enter); }
- if (dropEvents.move ) { this.dropTarget.fire(dropEvents.move ); }
-
- this.prevDropTarget = this.dropTarget;
- this.prevDropElement = this.dropElement;
-
- return dragEvent;
- },
-
- resizeStart: function (event) {
- var resizeEvent = new InteractEvent(this, event, 'resize', 'start', this.element);
-
- if (this.prepared.edges) {
- var startRect = this.target.getRect(this.element);
-
- if (this.target.options.resize.square) {
- var squareEdges = extend({}, this.prepared.edges);
-
- squareEdges.top = squareEdges.top || (squareEdges.left && !squareEdges.bottom);
- squareEdges.left = squareEdges.left || (squareEdges.top && !squareEdges.right );
- squareEdges.bottom = squareEdges.bottom || (squareEdges.right && !squareEdges.top );
- squareEdges.right = squareEdges.right || (squareEdges.bottom && !squareEdges.left );
-
- this.prepared._squareEdges = squareEdges;
- }
- else {
- this.prepared._squareEdges = null;
- }
-
- this.resizeRects = {
- start : startRect,
- current : extend({}, startRect),
- restricted: extend({}, startRect),
- previous : extend({}, startRect),
- delta : {
- left: 0, right : 0, width : 0,
- top : 0, bottom: 0, height: 0
- }
- };
-
- resizeEvent.rect = this.resizeRects.restricted;
- resizeEvent.deltaRect = this.resizeRects.delta;
- }
-
- this.target.fire(resizeEvent);
-
- this.resizing = true;
-
- return resizeEvent;
- },
-
- resizeMove: function (event) {
- var resizeEvent = new InteractEvent(this, event, 'resize', 'move', this.element);
-
- var edges = this.prepared.edges,
- invert = this.target.options.resize.invert,
- invertible = invert === 'reposition' || invert === 'negate';
-
- if (edges) {
- var dx = resizeEvent.dx,
- dy = resizeEvent.dy,
-
- start = this.resizeRects.start,
- current = this.resizeRects.current,
- restricted = this.resizeRects.restricted,
- delta = this.resizeRects.delta,
- previous = extend(this.resizeRects.previous, restricted);
-
- if (this.target.options.resize.square) {
- var originalEdges = edges;
-
- edges = this.prepared._squareEdges;
-
- if ((originalEdges.left && originalEdges.bottom)
- || (originalEdges.right && originalEdges.top)) {
- dy = -dx;
- }
- else if (originalEdges.left || originalEdges.right) { dy = dx; }
- else if (originalEdges.top || originalEdges.bottom) { dx = dy; }
- }
-
- // update the 'current' rect without modifications
- if (edges.top ) { current.top += dy; }
- if (edges.bottom) { current.bottom += dy; }
- if (edges.left ) { current.left += dx; }
- if (edges.right ) { current.right += dx; }
-
- if (invertible) {
- // if invertible, copy the current rect
- extend(restricted, current);
-
- if (invert === 'reposition') {
- // swap edge values if necessary to keep width/height positive
- var swap;
-
- if (restricted.top > restricted.bottom) {
- swap = restricted.top;
-
- restricted.top = restricted.bottom;
- restricted.bottom = swap;
- }
- if (restricted.left > restricted.right) {
- swap = restricted.left;
-
- restricted.left = restricted.right;
- restricted.right = swap;
- }
- }
- }
- else {
- // if not invertible, restrict to minimum of 0x0 rect
- restricted.top = Math.min(current.top, start.bottom);
- restricted.bottom = Math.max(current.bottom, start.top);
- restricted.left = Math.min(current.left, start.right);
- restricted.right = Math.max(current.right, start.left);
- }
-
- restricted.width = restricted.right - restricted.left;
- restricted.height = restricted.bottom - restricted.top ;
-
- for (var edge in restricted) {
- delta[edge] = restricted[edge] - previous[edge];
- }
-
- resizeEvent.edges = this.prepared.edges;
- resizeEvent.rect = restricted;
- resizeEvent.deltaRect = delta;
- }
-
- this.target.fire(resizeEvent);
-
- return resizeEvent;
- },
-
- gestureStart: function (event) {
- var gestureEvent = new InteractEvent(this, event, 'gesture', 'start', this.element);
-
- gestureEvent.ds = 0;
-
- this.gesture.startDistance = this.gesture.prevDistance = gestureEvent.distance;
- this.gesture.startAngle = this.gesture.prevAngle = gestureEvent.angle;
- this.gesture.scale = 1;
-
- this.gesturing = true;
-
- this.target.fire(gestureEvent);
-
- return gestureEvent;
- },
-
- gestureMove: function (event) {
- if (!this.pointerIds.length) {
- return this.prevEvent;
- }
-
- var gestureEvent;
-
- gestureEvent = new InteractEvent(this, event, 'gesture', 'move', this.element);
- gestureEvent.ds = gestureEvent.scale - this.gesture.scale;
-
- this.target.fire(gestureEvent);
-
- this.gesture.prevAngle = gestureEvent.angle;
- this.gesture.prevDistance = gestureEvent.distance;
-
- if (gestureEvent.scale !== Infinity &&
- gestureEvent.scale !== null &&
- gestureEvent.scale !== undefined &&
- !isNaN(gestureEvent.scale)) {
-
- this.gesture.scale = gestureEvent.scale;
- }
-
- return gestureEvent;
- },
-
- pointerHold: function (pointer, event, eventTarget) {
- this.collectEventTargets(pointer, event, eventTarget, 'hold');
- },
-
- pointerUp: function (pointer, event, eventTarget, curEventTarget) {
- var pointerIndex = this.mouse? 0 : indexOf(this.pointerIds, getPointerId(pointer));
-
- clearTimeout(this.holdTimers[pointerIndex]);
-
- this.collectEventTargets(pointer, event, eventTarget, 'up' );
- this.collectEventTargets(pointer, event, eventTarget, 'tap');
-
- this.pointerEnd(pointer, event, eventTarget, curEventTarget);
-
- this.removePointer(pointer);
- },
-
- pointerCancel: function (pointer, event, eventTarget, curEventTarget) {
- var pointerIndex = this.mouse? 0 : indexOf(this.pointerIds, getPointerId(pointer));
-
- clearTimeout(this.holdTimers[pointerIndex]);
-
- this.collectEventTargets(pointer, event, eventTarget, 'cancel');
- this.pointerEnd(pointer, event, eventTarget, curEventTarget);
-
- this.removePointer(pointer);
- },
-
- // http://www.quirksmode.org/dom/events/click.html
- // >Events leading to dblclick
- //
- // IE8 doesn't fire down event before dblclick.
- // This workaround tries to fire a tap and doubletap after dblclick
- ie8Dblclick: function (pointer, event, eventTarget) {
- if (this.prevTap
- && event.clientX === this.prevTap.clientX
- && event.clientY === this.prevTap.clientY
- && eventTarget === this.prevTap.target) {
-
- this.downTargets[0] = eventTarget;
- this.downTimes[0] = new Date().getTime();
- this.collectEventTargets(pointer, event, eventTarget, 'tap');
- }
- },
-
- // End interact move events and stop auto-scroll unless inertia is enabled
- pointerEnd: function (pointer, event, eventTarget, curEventTarget) {
- var endEvent,
- target = this.target,
- options = target && target.options,
- inertiaOptions = options && this.prepared.name && options[this.prepared.name].inertia,
- inertiaStatus = this.inertiaStatus;
-
- if (this.interacting()) {
-
- if (inertiaStatus.active) { return; }
-
- var pointerSpeed,
- now = new Date().getTime(),
- inertiaPossible = false,
- inertia = false,
- smoothEnd = false,
- endSnap = checkSnap(target, this.prepared.name) && options[this.prepared.name].snap.endOnly,
- endRestrict = checkRestrict(target, this.prepared.name) && options[this.prepared.name].restrict.endOnly,
- dx = 0,
- dy = 0,
- startEvent;
-
- if (this.dragging) {
- if (options.drag.axis === 'x' ) { pointerSpeed = Math.abs(this.pointerDelta.client.vx); }
- else if (options.drag.axis === 'y' ) { pointerSpeed = Math.abs(this.pointerDelta.client.vy); }
- else /*options.drag.axis === 'xy'*/{ pointerSpeed = this.pointerDelta.client.speed; }
- }
- else {
- pointerSpeed = this.pointerDelta.client.speed;
- }
-
- // check if inertia should be started
- inertiaPossible = (inertiaOptions && inertiaOptions.enabled
- && this.prepared.name !== 'gesture'
- && event !== inertiaStatus.startEvent);
-
- inertia = (inertiaPossible
- && (now - this.curCoords.timeStamp) < 50
- && pointerSpeed > inertiaOptions.minSpeed
- && pointerSpeed > inertiaOptions.endSpeed);
-
- if (inertiaPossible && !inertia && (endSnap || endRestrict)) {
-
- var snapRestrict = {};
-
- snapRestrict.snap = snapRestrict.restrict = snapRestrict;
-
- if (endSnap) {
- this.setSnapping(this.curCoords.page, snapRestrict);
- if (snapRestrict.locked) {
- dx += snapRestrict.dx;
- dy += snapRestrict.dy;
- }
- }
-
- if (endRestrict) {
- this.setRestriction(this.curCoords.page, snapRestrict);
- if (snapRestrict.restricted) {
- dx += snapRestrict.dx;
- dy += snapRestrict.dy;
- }
- }
-
- if (dx || dy) {
- smoothEnd = true;
- }
- }
-
- if (inertia || smoothEnd) {
- copyCoords(inertiaStatus.upCoords, this.curCoords);
-
- this.pointers[0] = inertiaStatus.startEvent = startEvent =
- new InteractEvent(this, event, this.prepared.name, 'inertiastart', this.element);
-
- inertiaStatus.t0 = now;
-
- target.fire(inertiaStatus.startEvent);
-
- if (inertia) {
- inertiaStatus.vx0 = this.pointerDelta.client.vx;
- inertiaStatus.vy0 = this.pointerDelta.client.vy;
- inertiaStatus.v0 = pointerSpeed;
-
- this.calcInertia(inertiaStatus);
-
- var page = extend({}, this.curCoords.page),
- origin = getOriginXY(target, this.element),
- statusObject;
-
- page.x = page.x + inertiaStatus.xe - origin.x;
- page.y = page.y + inertiaStatus.ye - origin.y;
-
- statusObject = {
- useStatusXY: true,
- x: page.x,
- y: page.y,
- dx: 0,
- dy: 0,
- snap: null
- };
-
- statusObject.snap = statusObject;
-
- dx = dy = 0;
-
- if (endSnap) {
- var snap = this.setSnapping(this.curCoords.page, statusObject);
-
- if (snap.locked) {
- dx += snap.dx;
- dy += snap.dy;
- }
- }
-
- if (endRestrict) {
- var restrict = this.setRestriction(this.curCoords.page, statusObject);
-
- if (restrict.restricted) {
- dx += restrict.dx;
- dy += restrict.dy;
- }
- }
-
- inertiaStatus.modifiedXe += dx;
- inertiaStatus.modifiedYe += dy;
-
- inertiaStatus.i = reqFrame(this.boundInertiaFrame);
- }
- else {
- inertiaStatus.smoothEnd = true;
- inertiaStatus.xe = dx;
- inertiaStatus.ye = dy;
-
- inertiaStatus.sx = inertiaStatus.sy = 0;
-
- inertiaStatus.i = reqFrame(this.boundSmoothEndFrame);
- }
-
- inertiaStatus.active = true;
- return;
- }
-
- if (endSnap || endRestrict) {
- // fire a move event at the snapped coordinates
- this.pointerMove(pointer, event, eventTarget, curEventTarget, true);
- }
- }
-
- if (this.dragging) {
- endEvent = new InteractEvent(this, event, 'drag', 'end', this.element);
-
- var draggableElement = this.element,
- drop = this.getDrop(endEvent, draggableElement);
-
- this.dropTarget = drop.dropzone;
- this.dropElement = drop.element;
-
- var dropEvents = this.getDropEvents(event, endEvent);
-
- if (dropEvents.leave) { this.prevDropTarget.fire(dropEvents.leave); }
- if (dropEvents.enter) { this.dropTarget.fire(dropEvents.enter); }
- if (dropEvents.drop ) { this.dropTarget.fire(dropEvents.drop ); }
- if (dropEvents.deactivate) {
- this.fireActiveDrops(dropEvents.deactivate);
- }
-
- target.fire(endEvent);
- }
- else if (this.resizing) {
- endEvent = new InteractEvent(this, event, 'resize', 'end', this.element);
- target.fire(endEvent);
- }
- else if (this.gesturing) {
- endEvent = new InteractEvent(this, event, 'gesture', 'end', this.element);
- target.fire(endEvent);
- }
-
- this.stop(event);
- },
-
- collectDrops: function (element) {
- var drops = [],
- elements = [],
- i;
-
- element = element || this.element;
-
- // collect all dropzones and their elements which qualify for a drop
- for (i = 0; i < interactables.length; i++) {
- if (!interactables[i].options.drop.enabled) { continue; }
-
- var current = interactables[i],
- accept = current.options.drop.accept;
-
- // test the draggable element against the dropzone's accept setting
- if ((isElement(accept) && accept !== element)
- || (isString(accept)
- && !matchesSelector(element, accept))) {
-
- continue;
- }
-
- // query for new elements if necessary
- var dropElements = current.selector? current._context.querySelectorAll(current.selector) : [current._element];
-
- for (var j = 0, len = dropElements.length; j < len; j++) {
- var currentElement = dropElements[j];
-
- if (currentElement === element) {
- continue;
- }
-
- drops.push(current);
- elements.push(currentElement);
- }
- }
-
- return {
- dropzones: drops,
- elements: elements
- };
- },
-
- fireActiveDrops: function (event) {
- var i,
- current,
- currentElement,
- prevElement;
-
- // loop through all active dropzones and trigger event
- for (i = 0; i < this.activeDrops.dropzones.length; i++) {
- current = this.activeDrops.dropzones[i];
- currentElement = this.activeDrops.elements [i];
-
- // prevent trigger of duplicate events on same element
- if (currentElement !== prevElement) {
- // set current element as event target
- event.target = currentElement;
- current.fire(event);
- }
- prevElement = currentElement;
- }
- },
-
- // Collect a new set of possible drops and save them in activeDrops.
- // setActiveDrops should always be called when a drag has just started or a
- // drag event happens while dynamicDrop is true
- setActiveDrops: function (dragElement) {
- // get dropzones and their elements that could receive the draggable
- var possibleDrops = this.collectDrops(dragElement, true);
-
- this.activeDrops.dropzones = possibleDrops.dropzones;
- this.activeDrops.elements = possibleDrops.elements;
- this.activeDrops.rects = [];
-
- for (var i = 0; i < this.activeDrops.dropzones.length; i++) {
- this.activeDrops.rects[i] = this.activeDrops.dropzones[i].getRect(this.activeDrops.elements[i]);
- }
- },
-
- getDrop: function (event, dragElement) {
- var validDrops = [];
-
- if (dynamicDrop) {
- this.setActiveDrops(dragElement);
- }
-
- // collect all dropzones and their elements which qualify for a drop
- for (var j = 0; j < this.activeDrops.dropzones.length; j++) {
- var current = this.activeDrops.dropzones[j],
- currentElement = this.activeDrops.elements [j],
- rect = this.activeDrops.rects [j];
-
- validDrops.push(current.dropCheck(this.pointers[0], this.target, dragElement, currentElement, rect)
- ? currentElement
- : null);
- }
-
- // get the most appropriate dropzone based on DOM depth and order
- var dropIndex = indexOfDeepestElement(validDrops),
- dropzone = this.activeDrops.dropzones[dropIndex] || null,
- element = this.activeDrops.elements [dropIndex] || null;
-
- return {
- dropzone: dropzone,
- element: element
- };
- },
-
- getDropEvents: function (pointerEvent, dragEvent) {
- var dropEvents = {
- enter : null,
- leave : null,
- activate : null,
- deactivate: null,
- move : null,
- drop : null
- };
-
- if (this.dropElement !== this.prevDropElement) {
- // if there was a prevDropTarget, create a dragleave event
- if (this.prevDropTarget) {
- dropEvents.leave = {
- target : this.prevDropElement,
- dropzone : this.prevDropTarget,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- timeStamp : dragEvent.timeStamp,
- type : 'dragleave'
- };
-
- dragEvent.dragLeave = this.prevDropElement;
- dragEvent.prevDropzone = this.prevDropTarget;
- }
- // if the dropTarget is not null, create a dragenter event
- if (this.dropTarget) {
- dropEvents.enter = {
- target : this.dropElement,
- dropzone : this.dropTarget,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- timeStamp : dragEvent.timeStamp,
- type : 'dragenter'
- };
-
- dragEvent.dragEnter = this.dropElement;
- dragEvent.dropzone = this.dropTarget;
- }
- }
-
- if (dragEvent.type === 'dragend' && this.dropTarget) {
- dropEvents.drop = {
- target : this.dropElement,
- dropzone : this.dropTarget,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- timeStamp : dragEvent.timeStamp,
- type : 'drop'
- };
-
- dragEvent.dropzone = this.dropTarget;
- }
- if (dragEvent.type === 'dragstart') {
- dropEvents.activate = {
- target : null,
- dropzone : null,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- timeStamp : dragEvent.timeStamp,
- type : 'dropactivate'
- };
- }
- if (dragEvent.type === 'dragend') {
- dropEvents.deactivate = {
- target : null,
- dropzone : null,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- timeStamp : dragEvent.timeStamp,
- type : 'dropdeactivate'
- };
- }
- if (dragEvent.type === 'dragmove' && this.dropTarget) {
- dropEvents.move = {
- target : this.dropElement,
- dropzone : this.dropTarget,
- relatedTarget: dragEvent.target,
- draggable : dragEvent.interactable,
- dragEvent : dragEvent,
- interaction : this,
- dragmove : dragEvent,
- timeStamp : dragEvent.timeStamp,
- type : 'dropmove'
- };
- dragEvent.dropzone = this.dropTarget;
- }
-
- return dropEvents;
- },
-
- currentAction: function () {
- return (this.dragging && 'drag') || (this.resizing && 'resize') || (this.gesturing && 'gesture') || null;
- },
-
- interacting: function () {
- return this.dragging || this.resizing || this.gesturing;
- },
-
- clearTargets: function () {
- this.target = this.element = null;
-
- this.dropTarget = this.dropElement = this.prevDropTarget = this.prevDropElement = null;
- },
-
- stop: function (event) {
- if (this.interacting()) {
- autoScroll.stop();
- this.matches = [];
- this.matchElements = [];
-
- var target = this.target;
-
- if (target.options.styleCursor) {
- target._doc.documentElement.style.cursor = '';
- }
-
- // prevent Default only if were previously interacting
- if (event && isFunction(event.preventDefault)) {
- this.checkAndPreventDefault(event, target, this.element);
- }
-
- if (this.dragging) {
- this.activeDrops.dropzones = this.activeDrops.elements = this.activeDrops.rects = null;
- }
-
- this.clearTargets();
- }
-
- this.pointerIsDown = this.snapStatus.locked = this.dragging = this.resizing = this.gesturing = false;
- this.prepared.name = this.prevEvent = null;
- this.inertiaStatus.resumeDx = this.inertiaStatus.resumeDy = 0;
-
- // remove pointers if their ID isn't in this.pointerIds
- for (var i = 0; i < this.pointers.length; i++) {
- if (indexOf(this.pointerIds, getPointerId(this.pointers[i])) === -1) {
- this.pointers.splice(i, 1);
- }
- }
-
- for (i = 0; i < interactions.length; i++) {
- // remove this interaction if it's not the only one of it's type
- if (interactions[i] !== this && interactions[i].mouse === this.mouse) {
- interactions.splice(indexOf(interactions, this), 1);
- }
- }
- },
-
- inertiaFrame: function () {
- var inertiaStatus = this.inertiaStatus,
- options = this.target.options[this.prepared.name].inertia,
- lambda = options.resistance,
- t = new Date().getTime() / 1000 - inertiaStatus.t0;
-
- if (t < inertiaStatus.te) {
-
- var progress = 1 - (Math.exp(-lambda * t) - inertiaStatus.lambda_v0) / inertiaStatus.one_ve_v0;
-
- if (inertiaStatus.modifiedXe === inertiaStatus.xe && inertiaStatus.modifiedYe === inertiaStatus.ye) {
- inertiaStatus.sx = inertiaStatus.xe * progress;
- inertiaStatus.sy = inertiaStatus.ye * progress;
- }
- else {
- var quadPoint = getQuadraticCurvePoint(
- 0, 0,
- inertiaStatus.xe, inertiaStatus.ye,
- inertiaStatus.modifiedXe, inertiaStatus.modifiedYe,
- progress);
-
- inertiaStatus.sx = quadPoint.x;
- inertiaStatus.sy = quadPoint.y;
- }
-
- this.pointerMove(inertiaStatus.startEvent, inertiaStatus.startEvent);
-
- inertiaStatus.i = reqFrame(this.boundInertiaFrame);
- }
- else {
- inertiaStatus.sx = inertiaStatus.modifiedXe;
- inertiaStatus.sy = inertiaStatus.modifiedYe;
-
- this.pointerMove(inertiaStatus.startEvent, inertiaStatus.startEvent);
-
- inertiaStatus.active = false;
- this.pointerEnd(inertiaStatus.startEvent, inertiaStatus.startEvent);
- }
- },
-
- smoothEndFrame: function () {
- var inertiaStatus = this.inertiaStatus,
- t = new Date().getTime() - inertiaStatus.t0,
- duration = this.target.options[this.prepared.name].inertia.smoothEndDuration;
-
- if (t < duration) {
- inertiaStatus.sx = easeOutQuad(t, 0, inertiaStatus.xe, duration);
- inertiaStatus.sy = easeOutQuad(t, 0, inertiaStatus.ye, duration);
-
- this.pointerMove(inertiaStatus.startEvent, inertiaStatus.startEvent);
-
- inertiaStatus.i = reqFrame(this.boundSmoothEndFrame);
- }
- else {
- inertiaStatus.sx = inertiaStatus.xe;
- inertiaStatus.sy = inertiaStatus.ye;
-
- this.pointerMove(inertiaStatus.startEvent, inertiaStatus.startEvent);
-
- inertiaStatus.active = false;
- inertiaStatus.smoothEnd = false;
-
- this.pointerEnd(inertiaStatus.startEvent, inertiaStatus.startEvent);
- }
- },
-
- addPointer: function (pointer) {
- var id = getPointerId(pointer),
- index = this.mouse? 0 : indexOf(this.pointerIds, id);
-
- if (index === -1) {
- index = this.pointerIds.length;
- }
-
- this.pointerIds[index] = id;
- this.pointers[index] = pointer;
-
- return index;
- },
-
- removePointer: function (pointer) {
- var id = getPointerId(pointer),
- index = this.mouse? 0 : indexOf(this.pointerIds, id);
-
- if (index === -1) { return; }
-
- if (!this.interacting()) {
- this.pointers.splice(index, 1);
- }
-
- this.pointerIds .splice(index, 1);
- this.downTargets.splice(index, 1);
- this.downTimes .splice(index, 1);
- this.holdTimers .splice(index, 1);
- },
-
- recordPointer: function (pointer) {
- // Do not update pointers while inertia is active.
- // The inertia start event should be this.pointers[0]
- if (this.inertiaStatus.active) { return; }
-
- var index = this.mouse? 0: indexOf(this.pointerIds, getPointerId(pointer));
-
- if (index === -1) { return; }
-
- this.pointers[index] = pointer;
- },
-
- collectEventTargets: function (pointer, event, eventTarget, eventType) {
- var pointerIndex = this.mouse? 0 : indexOf(this.pointerIds, getPointerId(pointer));
-
- // do not fire a tap event if the pointer was moved before being lifted
- if (eventType === 'tap' && (this.pointerWasMoved
- // or if the pointerup target is different to the pointerdown target
- || !(this.downTargets[pointerIndex] && this.downTargets[pointerIndex] === eventTarget))) {
- return;
- }
-
- var targets = [],
- elements = [],
- element = eventTarget;
-
- function collectSelectors (interactable, selector, context) {
- var els = ie8MatchesSelector
- ? context.querySelectorAll(selector)
- : undefined;
-
- if (interactable._iEvents[eventType]
- && isElement(element)
- && inContext(interactable, element)
- && !testIgnore(interactable, element, eventTarget)
- && testAllow(interactable, element, eventTarget)
- && matchesSelector(element, selector, els)) {
-
- targets.push(interactable);
- elements.push(element);
- }
- }
-
- while (element) {
- if (interact.isSet(element) && interact(element)._iEvents[eventType]) {
- targets.push(interact(element));
- elements.push(element);
- }
-
- interactables.forEachSelector(collectSelectors);
-
- element = parentElement(element);
- }
-
- // create the tap event even if there are no listeners so that
- // doubletap can still be created and fired
- if (targets.length || eventType === 'tap') {
- this.firePointers(pointer, event, eventTarget, targets, elements, eventType);
- }
- },
-
- firePointers: function (pointer, event, eventTarget, targets, elements, eventType) {
- var pointerIndex = this.mouse? 0 : indexOf(getPointerId(pointer)),
- pointerEvent = {},
- i,
- // for tap events
- interval, createNewDoubleTap;
-
- // if it's a doubletap then the event properties would have been
- // copied from the tap event and provided as the pointer argument
- if (eventType === 'doubletap') {
- pointerEvent = pointer;
- }
- else {
- extend(pointerEvent, event);
- if (event !== pointer) {
- extend(pointerEvent, pointer);
- }
-
- pointerEvent.preventDefault = preventOriginalDefault;
- pointerEvent.stopPropagation = InteractEvent.prototype.stopPropagation;
- pointerEvent.stopImmediatePropagation = InteractEvent.prototype.stopImmediatePropagation;
- pointerEvent.interaction = this;
-
- pointerEvent.timeStamp = new Date().getTime();
- pointerEvent.originalEvent = event;
- pointerEvent.type = eventType;
- pointerEvent.pointerId = getPointerId(pointer);
- pointerEvent.pointerType = this.mouse? 'mouse' : !supportsPointerEvent? 'touch'
- : isString(pointer.pointerType)
- ? pointer.pointerType
- : [,,'touch', 'pen', 'mouse'][pointer.pointerType];
- }
-
- if (eventType === 'tap') {
- pointerEvent.dt = pointerEvent.timeStamp - this.downTimes[pointerIndex];
-
- interval = pointerEvent.timeStamp - this.tapTime;
- createNewDoubleTap = !!(this.prevTap && this.prevTap.type !== 'doubletap'
- && this.prevTap.target === pointerEvent.target
- && interval < 500);
-
- pointerEvent.double = createNewDoubleTap;
-
- this.tapTime = pointerEvent.timeStamp;
- }
-
- for (i = 0; i < targets.length; i++) {
- pointerEvent.currentTarget = elements[i];
- pointerEvent.interactable = targets[i];
- targets[i].fire(pointerEvent);
-
- if (pointerEvent.immediatePropagationStopped
- ||(pointerEvent.propagationStopped && elements[i + 1] !== pointerEvent.currentTarget)) {
- break;
- }
- }
-
- if (createNewDoubleTap) {
- var doubleTap = {};
-
- extend(doubleTap, pointerEvent);
-
- doubleTap.dt = interval;
- doubleTap.type = 'doubletap';
-
- this.collectEventTargets(doubleTap, event, eventTarget, 'doubletap');
-
- this.prevTap = doubleTap;
- }
- else if (eventType === 'tap') {
- this.prevTap = pointerEvent;
- }
- },
-
- validateSelector: function (pointer, matches, matchElements) {
- for (var i = 0, len = matches.length; i < len; i++) {
- var match = matches[i],
- matchElement = matchElements[i],
- action = validateAction(match.getAction(pointer, this, matchElement), match);
-
- if (action && withinInteractionLimit(match, matchElement, action)) {
- this.target = match;
- this.element = matchElement;
-
- return action;
- }
- }
- },
-
- setSnapping: function (pageCoords, status) {
- var snap = this.target.options[this.prepared.name].snap,
- targets = [],
- target,
- page,
- i;
-
- status = status || this.snapStatus;
-
- if (status.useStatusXY) {
- page = { x: status.x, y: status.y };
- }
- else {
- var origin = getOriginXY(this.target, this.element);
-
- page = extend({}, pageCoords);
-
- page.x -= origin.x;
- page.y -= origin.y;
- }
-
- status.realX = page.x;
- status.realY = page.y;
-
- page.x = page.x - this.inertiaStatus.resumeDx;
- page.y = page.y - this.inertiaStatus.resumeDy;
-
- var len = snap.targets? snap.targets.length : 0;
-
- for (var relIndex = 0; relIndex < this.snapOffsets.length; relIndex++) {
- var relative = {
- x: page.x - this.snapOffsets[relIndex].x,
- y: page.y - this.snapOffsets[relIndex].y
- };
-
- for (i = 0; i < len; i++) {
- if (isFunction(snap.targets[i])) {
- target = snap.targets[i](relative.x, relative.y, this);
- }
- else {
- target = snap.targets[i];
- }
-
- if (!target) { continue; }
-
- targets.push({
- x: isNumber(target.x) ? (target.x + this.snapOffsets[relIndex].x) : relative.x,
- y: isNumber(target.y) ? (target.y + this.snapOffsets[relIndex].y) : relative.y,
-
- range: isNumber(target.range)? target.range: snap.range
- });
- }
- }
-
- var closest = {
- target: null,
- inRange: false,
- distance: 0,
- range: 0,
- dx: 0,
- dy: 0
- };
-
- for (i = 0, len = targets.length; i < len; i++) {
- target = targets[i];
-
- var range = target.range,
- dx = target.x - page.x,
- dy = target.y - page.y,
- distance = hypot(dx, dy),
- inRange = distance <= range;
-
- // Infinite targets count as being out of range
- // compared to non infinite ones that are in range
- if (range === Infinity && closest.inRange && closest.range !== Infinity) {
- inRange = false;
- }
-
- if (!closest.target || (inRange
- // is the closest target in range?
- ? (closest.inRange && range !== Infinity
- // the pointer is relatively deeper in this target
- ? distance / range < closest.distance / closest.range
- // this target has Infinite range and the closest doesn't
- : (range === Infinity && closest.range !== Infinity)
- // OR this target is closer that the previous closest
- || distance < closest.distance)
- // The other is not in range and the pointer is closer to this target
- : (!closest.inRange && distance < closest.distance))) {
-
- if (range === Infinity) {
- inRange = true;
- }
-
- closest.target = target;
- closest.distance = distance;
- closest.range = range;
- closest.inRange = inRange;
- closest.dx = dx;
- closest.dy = dy;
-
- status.range = range;
- }
- }
-
- var snapChanged;
-
- if (closest.target) {
- snapChanged = (status.snappedX !== closest.target.x || status.snappedY !== closest.target.y);
-
- status.snappedX = closest.target.x;
- status.snappedY = closest.target.y;
- }
- else {
- snapChanged = true;
-
- status.snappedX = NaN;
- status.snappedY = NaN;
- }
-
- status.dx = closest.dx;
- status.dy = closest.dy;
-
- status.changed = (snapChanged || (closest.inRange && !status.locked));
- status.locked = closest.inRange;
-
- return status;
- },
-
- setRestriction: function (pageCoords, status) {
- var target = this.target,
- restrict = target && target.options[this.prepared.name].restrict,
- restriction = restrict && restrict.restriction,
- page;
-
- if (!restriction) {
- return status;
- }
-
- status = status || this.restrictStatus;
-
- page = status.useStatusXY
- ? page = { x: status.x, y: status.y }
- : page = extend({}, pageCoords);
-
- if (status.snap && status.snap.locked) {
- page.x += status.snap.dx || 0;
- page.y += status.snap.dy || 0;
- }
-
- page.x -= this.inertiaStatus.resumeDx;
- page.y -= this.inertiaStatus.resumeDy;
-
- status.dx = 0;
- status.dy = 0;
- status.restricted = false;
-
- var rect, restrictedX, restrictedY;
-
- if (isString(restriction)) {
- if (restriction === 'parent') {
- restriction = parentElement(this.element);
- }
- else if (restriction === 'self') {
- restriction = target.getRect(this.element);
- }
- else {
- restriction = closest(this.element, restriction);
- }
-
- if (!restriction) { return status; }
- }
-
- if (isFunction(restriction)) {
- restriction = restriction(page.x, page.y, this.element);
- }
-
- if (isElement(restriction)) {
- restriction = getElementRect(restriction);
- }
-
- rect = restriction;
-
- if (!restriction) {
- restrictedX = page.x;
- restrictedY = page.y;
- }
- // object is assumed to have
- // x, y, width, height or
- // left, top, right, bottom
- else if ('x' in restriction && 'y' in restriction) {
- restrictedX = Math.max(Math.min(rect.x + rect.width - this.restrictOffset.right , page.x), rect.x + this.restrictOffset.left);
- restrictedY = Math.max(Math.min(rect.y + rect.height - this.restrictOffset.bottom, page.y), rect.y + this.restrictOffset.top );
- }
- else {
- restrictedX = Math.max(Math.min(rect.right - this.restrictOffset.right , page.x), rect.left + this.restrictOffset.left);
- restrictedY = Math.max(Math.min(rect.bottom - this.restrictOffset.bottom, page.y), rect.top + this.restrictOffset.top );
- }
-
- status.dx = restrictedX - page.x;
- status.dy = restrictedY - page.y;
-
- status.changed = status.restrictedX !== restrictedX || status.restrictedY !== restrictedY;
- status.restricted = !!(status.dx || status.dy);
-
- status.restrictedX = restrictedX;
- status.restrictedY = restrictedY;
-
- return status;
- },
-
- checkAndPreventDefault: function (event, interactable, element) {
- if (!(interactable = interactable || this.target)) { return; }
-
- var options = interactable.options,
- prevent = options.preventDefault;
-
- if (prevent === 'auto' && element && !/^(input|select|textarea)$/i.test(event.target.nodeName)) {
- // do not preventDefault on pointerdown if the prepared action is a drag
- // and dragging can only start from a certain direction - this allows
- // a touch to pan the viewport if a drag isn't in the right direction
- if (/down|start/i.test(event.type)
- && this.prepared.name === 'drag' && options.drag.axis !== 'xy') {
-
- return;
- }
-
- // with manualStart, only preventDefault while interacting
- if (options[this.prepared.name] && options[this.prepared.name].manualStart
- && !this.interacting()) {
- return;
- }
-
- event.preventDefault();
- return;
- }
-
- if (prevent === 'always') {
- event.preventDefault();
- return;
- }
- },
-
- calcInertia: function (status) {
- var inertiaOptions = this.target.options[this.prepared.name].inertia,
- lambda = inertiaOptions.resistance,
- inertiaDur = -Math.log(inertiaOptions.endSpeed / status.v0) / lambda;
-
- status.x0 = this.prevEvent.pageX;
- status.y0 = this.prevEvent.pageY;
- status.t0 = status.startEvent.timeStamp / 1000;
- status.sx = status.sy = 0;
-
- status.modifiedXe = status.xe = (status.vx0 - inertiaDur) / lambda;
- status.modifiedYe = status.ye = (status.vy0 - inertiaDur) / lambda;
- status.te = inertiaDur;
-
- status.lambda_v0 = lambda / status.v0;
- status.one_ve_v0 = 1 - inertiaOptions.endSpeed / status.v0;
- },
-
- autoScrollMove: function (pointer) {
- if (!(this.interacting()
- && checkAutoScroll(this.target, this.prepared.name))) {
- return;
- }
-
- if (this.inertiaStatus.active) {
- autoScroll.x = autoScroll.y = 0;
- return;
- }
-
- var top,
- right,
- bottom,
- left,
- options = this.target.options[this.prepared.name].autoScroll,
- container = options.container || getWindow(this.element);
-
- if (isWindow(container)) {
- left = pointer.clientX < autoScroll.margin;
- top = pointer.clientY < autoScroll.margin;
- right = pointer.clientX > container.innerWidth - autoScroll.margin;
- bottom = pointer.clientY > container.innerHeight - autoScroll.margin;
- }
- else {
- var rect = getElementRect(container);
-
- left = pointer.clientX < rect.left + autoScroll.margin;
- top = pointer.clientY < rect.top + autoScroll.margin;
- right = pointer.clientX > rect.right - autoScroll.margin;
- bottom = pointer.clientY > rect.bottom - autoScroll.margin;
- }
-
- autoScroll.x = (right ? 1: left? -1: 0);
- autoScroll.y = (bottom? 1: top? -1: 0);
-
- if (!autoScroll.isScrolling) {
- // set the autoScroll properties to those of the target
- autoScroll.margin = options.margin;
- autoScroll.speed = options.speed;
-
- autoScroll.start(this);
- }
- },
-
- _updateEventTargets: function (target, currentTarget) {
- this._eventTarget = target;
- this._curEventTarget = currentTarget;
- }
-
- };
-
- function getInteractionFromPointer (pointer, eventType, eventTarget) {
- var i = 0, len = interactions.length,
- mouseEvent = (/mouse/i.test(pointer.pointerType || eventType)
- // MSPointerEvent.MSPOINTER_TYPE_MOUSE
- || pointer.pointerType === 4),
- interaction;
-
- var id = getPointerId(pointer);
-
- // try to resume inertia with a new pointer
- if (/down|start/i.test(eventType)) {
- for (i = 0; i < len; i++) {
- interaction = interactions[i];
-
- var element = eventTarget;
-
- if (interaction.inertiaStatus.active && interaction.target.options[interaction.prepared.name].inertia.allowResume
- && (interaction.mouse === mouseEvent)) {
- while (element) {
- // if the element is the interaction element
- if (element === interaction.element) {
- // update the interaction's pointer
- if (interaction.pointers[0]) {
- interaction.removePointer(interaction.pointers[0]);
- }
- interaction.addPointer(pointer);
-
- return interaction;
- }
- element = parentElement(element);
- }
- }
- }
- }
-
- // if it's a mouse interaction
- if (mouseEvent || !(supportsTouch || supportsPointerEvent)) {
-
- // find a mouse interaction that's not in inertia phase
- for (i = 0; i < len; i++) {
- if (interactions[i].mouse && !interactions[i].inertiaStatus.active) {
- return interactions[i];
- }
- }
-
- // find any interaction specifically for mouse.
- // if the eventType is a mousedown, and inertia is active
- // ignore the interaction
- for (i = 0; i < len; i++) {
- if (interactions[i].mouse && !(/down/.test(eventType) && interactions[i].inertiaStatus.active)) {
- return interaction;
- }
- }
-
- // create a new interaction for mouse
- interaction = new Interaction();
- interaction.mouse = true;
-
- return interaction;
- }
-
- // get interaction that has this pointer
- for (i = 0; i < len; i++) {
- if (contains(interactions[i].pointerIds, id)) {
- return interactions[i];
- }
- }
-
- // at this stage, a pointerUp should not return an interaction
- if (/up|end|out/i.test(eventType)) {
- return null;
- }
-
- // get first idle interaction
- for (i = 0; i < len; i++) {
- interaction = interactions[i];
-
- if ((!interaction.prepared.name || (interaction.target.options.gesture.enabled))
- && !interaction.interacting()
- && !(!mouseEvent && interaction.mouse)) {
-
- interaction.addPointer(pointer);
-
- return interaction;
- }
- }
-
- return new Interaction();
- }
-
- function doOnInteractions (method) {
- return (function (event) {
- var interaction,
- eventTarget = getActualElement(event.path
- ? event.path[0]
- : event.target),
- curEventTarget = getActualElement(event.currentTarget),
- i;
-
- if (supportsTouch && /touch/.test(event.type)) {
- prevTouchTime = new Date().getTime();
-
- for (i = 0; i < event.changedTouches.length; i++) {
- var pointer = event.changedTouches[i];
-
- interaction = getInteractionFromPointer(pointer, event.type, eventTarget);
-
- if (!interaction) { continue; }
-
- interaction._updateEventTargets(eventTarget, curEventTarget);
-
- interaction[method](pointer, event, eventTarget, curEventTarget);
- }
- }
- else {
- if (!supportsPointerEvent && /mouse/.test(event.type)) {
- // ignore mouse events while touch interactions are active
- for (i = 0; i < interactions.length; i++) {
- if (!interactions[i].mouse && interactions[i].pointerIsDown) {
- return;
- }
- }
-
- // try to ignore mouse events that are simulated by the browser
- // after a touch event
- if (new Date().getTime() - prevTouchTime < 500) {
- return;
- }
- }
-
- interaction = getInteractionFromPointer(event, event.type, eventTarget);
-
- if (!interaction) { return; }
-
- interaction._updateEventTargets(eventTarget, curEventTarget);
-
- interaction[method](event, event, eventTarget, curEventTarget);
- }
- });
- }
-
- function InteractEvent (interaction, event, action, phase, element, related) {
- var client,
- page,
- target = interaction.target,
- snapStatus = interaction.snapStatus,
- restrictStatus = interaction.restrictStatus,
- pointers = interaction.pointers,
- deltaSource = (target && target.options || defaultOptions).deltaSource,
- sourceX = deltaSource + 'X',
- sourceY = deltaSource + 'Y',
- options = target? target.options: defaultOptions,
- origin = getOriginXY(target, element),
- starting = phase === 'start',
- ending = phase === 'end',
- coords = starting? interaction.startCoords : interaction.curCoords;
-
- element = element || interaction.element;
-
- page = extend({}, coords.page);
- client = extend({}, coords.client);
-
- page.x -= origin.x;
- page.y -= origin.y;
-
- client.x -= origin.x;
- client.y -= origin.y;
-
- var relativePoints = options[action].snap && options[action].snap.relativePoints ;
-
- if (checkSnap(target, action) && !(starting && relativePoints && relativePoints.length)) {
- this.snap = {
- range : snapStatus.range,
- locked : snapStatus.locked,
- x : snapStatus.snappedX,
- y : snapStatus.snappedY,
- realX : snapStatus.realX,
- realY : snapStatus.realY,
- dx : snapStatus.dx,
- dy : snapStatus.dy
- };
-
- if (snapStatus.locked) {
- page.x += snapStatus.dx;
- page.y += snapStatus.dy;
- client.x += snapStatus.dx;
- client.y += snapStatus.dy;
- }
- }
-
- if (checkRestrict(target, action) && !(starting && options[action].restrict.elementRect) && restrictStatus.restricted) {
- page.x += restrictStatus.dx;
- page.y += restrictStatus.dy;
- client.x += restrictStatus.dx;
- client.y += restrictStatus.dy;
-
- this.restrict = {
- dx: restrictStatus.dx,
- dy: restrictStatus.dy
- };
- }
-
- this.pageX = page.x;
- this.pageY = page.y;
- this.clientX = client.x;
- this.clientY = client.y;
-
- this.x0 = interaction.startCoords.page.x - origin.x;
- this.y0 = interaction.startCoords.page.y - origin.y;
- this.clientX0 = interaction.startCoords.client.x - origin.x;
- this.clientY0 = interaction.startCoords.client.y - origin.y;
- this.ctrlKey = event.ctrlKey;
- this.altKey = event.altKey;
- this.shiftKey = event.shiftKey;
- this.metaKey = event.metaKey;
- this.button = event.button;
- this.target = element;
- this.t0 = interaction.downTimes[0];
- this.type = action + (phase || '');
-
- this.interaction = interaction;
- this.interactable = target;
-
- var inertiaStatus = interaction.inertiaStatus;
-
- if (inertiaStatus.active) {
- this.detail = 'inertia';
- }
-
- if (related) {
- this.relatedTarget = related;
- }
-
- // end event dx, dy is difference between start and end points
- if (ending) {
- if (deltaSource === 'client') {
- this.dx = client.x - interaction.startCoords.client.x;
- this.dy = client.y - interaction.startCoords.client.y;
- }
- else {
- this.dx = page.x - interaction.startCoords.page.x;
- this.dy = page.y - interaction.startCoords.page.y;
- }
- }
- else if (starting) {
- this.dx = 0;
- this.dy = 0;
- }
- // copy properties from previousmove if starting inertia
- else if (phase === 'inertiastart') {
- this.dx = interaction.prevEvent.dx;
- this.dy = interaction.prevEvent.dy;
- }
- else {
- if (deltaSource === 'client') {
- this.dx = client.x - interaction.prevEvent.clientX;
- this.dy = client.y - interaction.prevEvent.clientY;
- }
- else {
- this.dx = page.x - interaction.prevEvent.pageX;
- this.dy = page.y - interaction.prevEvent.pageY;
- }
- }
- if (interaction.prevEvent && interaction.prevEvent.detail === 'inertia'
- && !inertiaStatus.active
- && options[action].inertia && options[action].inertia.zeroResumeDelta) {
-
- inertiaStatus.resumeDx += this.dx;
- inertiaStatus.resumeDy += this.dy;
-
- this.dx = this.dy = 0;
- }
-
- if (action === 'resize' && interaction.resizeAxes) {
- if (options.resize.square) {
- if (interaction.resizeAxes === 'y') {
- this.dx = this.dy;
- }
- else {
- this.dy = this.dx;
- }
- this.axes = 'xy';
- }
- else {
- this.axes = interaction.resizeAxes;
-
- if (interaction.resizeAxes === 'x') {
- this.dy = 0;
- }
- else if (interaction.resizeAxes === 'y') {
- this.dx = 0;
- }
- }
- }
- else if (action === 'gesture') {
- this.touches = [pointers[0], pointers[1]];
-
- if (starting) {
- this.distance = touchDistance(pointers, deltaSource);
- this.box = touchBBox(pointers);
- this.scale = 1;
- this.ds = 0;
- this.angle = touchAngle(pointers, undefined, deltaSource);
- this.da = 0;
- }
- else if (ending || event instanceof InteractEvent) {
- this.distance = interaction.prevEvent.distance;
- this.box = interaction.prevEvent.box;
- this.scale = interaction.prevEvent.scale;
- this.ds = this.scale - 1;
- this.angle = interaction.prevEvent.angle;
- this.da = this.angle - interaction.gesture.startAngle;
- }
- else {
- this.distance = touchDistance(pointers, deltaSource);
- this.box = touchBBox(pointers);
- this.scale = this.distance / interaction.gesture.startDistance;
- this.angle = touchAngle(pointers, interaction.gesture.prevAngle, deltaSource);
-
- this.ds = this.scale - interaction.gesture.prevScale;
- this.da = this.angle - interaction.gesture.prevAngle;
- }
- }
-
- if (starting) {
- this.timeStamp = interaction.downTimes[0];
- this.dt = 0;
- this.duration = 0;
- this.speed = 0;
- this.velocityX = 0;
- this.velocityY = 0;
- }
- else if (phase === 'inertiastart') {
- this.timeStamp = interaction.prevEvent.timeStamp;
- this.dt = interaction.prevEvent.dt;
- this.duration = interaction.prevEvent.duration;
- this.speed = interaction.prevEvent.speed;
- this.velocityX = interaction.prevEvent.velocityX;
- this.velocityY = interaction.prevEvent.velocityY;
- }
- else {
- this.timeStamp = new Date().getTime();
- this.dt = this.timeStamp - interaction.prevEvent.timeStamp;
- this.duration = this.timeStamp - interaction.downTimes[0];
-
- if (event instanceof InteractEvent) {
- var dx = this[sourceX] - interaction.prevEvent[sourceX],
- dy = this[sourceY] - interaction.prevEvent[sourceY],
- dt = this.dt / 1000;
-
- this.speed = hypot(dx, dy) / dt;
- this.velocityX = dx / dt;
- this.velocityY = dy / dt;
- }
- // if normal move or end event, use previous user event coords
- else {
- // speed and velocity in pixels per second
- this.speed = interaction.pointerDelta[deltaSource].speed;
- this.velocityX = interaction.pointerDelta[deltaSource].vx;
- this.velocityY = interaction.pointerDelta[deltaSource].vy;
- }
- }
-
- if ((ending || phase === 'inertiastart')
- && interaction.prevEvent.speed > 600 && this.timeStamp - interaction.prevEvent.timeStamp < 150) {
-
- var angle = 180 * Math.atan2(interaction.prevEvent.velocityY, interaction.prevEvent.velocityX) / Math.PI,
- overlap = 22.5;
-
- if (angle < 0) {
- angle += 360;
- }
-
- var left = 135 - overlap <= angle && angle < 225 + overlap,
- up = 225 - overlap <= angle && angle < 315 + overlap,
-
- right = !left && (315 - overlap <= angle || angle < 45 + overlap),
- down = !up && 45 - overlap <= angle && angle < 135 + overlap;
-
- this.swipe = {
- up : up,
- down : down,
- left : left,
- right: right,
- angle: angle,
- speed: interaction.prevEvent.speed,
- velocity: {
- x: interaction.prevEvent.velocityX,
- y: interaction.prevEvent.velocityY
- }
- };
- }
- }
-
- InteractEvent.prototype = {
- preventDefault: blank,
- stopImmediatePropagation: function () {
- this.immediatePropagationStopped = this.propagationStopped = true;
- },
- stopPropagation: function () {
- this.propagationStopped = true;
- }
- };
-
- function preventOriginalDefault () {
- this.originalEvent.preventDefault();
- }
-
- function getActionCursor (action) {
- var cursor = '';
-
- if (action.name === 'drag') {
- cursor = actionCursors.drag;
- }
- if (action.name === 'resize') {
- if (action.axis) {
- cursor = actionCursors[action.name + action.axis];
- }
- else if (action.edges) {
- var cursorKey = 'resize',
- edgeNames = ['top', 'bottom', 'left', 'right'];
-
- for (var i = 0; i < 4; i++) {
- if (action.edges[edgeNames[i]]) {
- cursorKey += edgeNames[i];
- }
- }
-
- cursor = actionCursors[cursorKey];
- }
- }
-
- return cursor;
- }
-
- function checkResizeEdge (name, value, page, element, interactableElement, rect, margin) {
- // false, '', undefined, null
- if (!value) { return false; }
-
- // true value, use pointer coords and element rect
- if (value === true) {
- // if dimensions are negative, "switch" edges
- var width = isNumber(rect.width)? rect.width : rect.right - rect.left,
- height = isNumber(rect.height)? rect.height : rect.bottom - rect.top;
-
- if (width < 0) {
- if (name === 'left' ) { name = 'right'; }
- else if (name === 'right') { name = 'left' ; }
- }
- if (height < 0) {
- if (name === 'top' ) { name = 'bottom'; }
- else if (name === 'bottom') { name = 'top' ; }
- }
-
- if (name === 'left' ) { return page.x < ((width >= 0? rect.left: rect.right ) + margin); }
- if (name === 'top' ) { return page.y < ((height >= 0? rect.top : rect.bottom) + margin); }
-
- if (name === 'right' ) { return page.x > ((width >= 0? rect.right : rect.left) - margin); }
- if (name === 'bottom') { return page.y > ((height >= 0? rect.bottom: rect.top ) - margin); }
- }
-
- // the remaining checks require an element
- if (!isElement(element)) { return false; }
-
- return isElement(value)
- // the value is an element to use as a resize handle
- ? value === element
- // otherwise check if element matches value as selector
- : matchesUpTo(element, value, interactableElement);
- }
-
- function defaultActionChecker (pointer, interaction, element) {
- var rect = this.getRect(element),
- shouldResize = false,
- action = null,
- resizeAxes = null,
- resizeEdges,
- page = extend({}, interaction.curCoords.page),
- options = this.options;
-
- if (!rect) { return null; }
-
- if (actionIsEnabled.resize && options.resize.enabled) {
- var resizeOptions = options.resize;
-
- resizeEdges = {
- left: false, right: false, top: false, bottom: false
- };
-
- // if using resize.edges
- if (isObject(resizeOptions.edges)) {
- for (var edge in resizeEdges) {
- resizeEdges[edge] = checkResizeEdge(edge,
- resizeOptions.edges[edge],
- page,
- interaction._eventTarget,
- element,
- rect,
- resizeOptions.margin || margin);
- }
-
- resizeEdges.left = resizeEdges.left && !resizeEdges.right;
- resizeEdges.top = resizeEdges.top && !resizeEdges.bottom;
-
- shouldResize = resizeEdges.left || resizeEdges.right || resizeEdges.top || resizeEdges.bottom;
- }
- else {
- var right = options.resize.axis !== 'y' && page.x > (rect.right - margin),
- bottom = options.resize.axis !== 'x' && page.y > (rect.bottom - margin);
-
- shouldResize = right || bottom;
- resizeAxes = (right? 'x' : '') + (bottom? 'y' : '');
- }
- }
-
- action = shouldResize
- ? 'resize'
- : actionIsEnabled.drag && options.drag.enabled
- ? 'drag'
- : null;
-
- if (actionIsEnabled.gesture
- && interaction.pointerIds.length >=2
- && !(interaction.dragging || interaction.resizing)) {
- action = 'gesture';
- }
-
- if (action) {
- return {
- name: action,
- axis: resizeAxes,
- edges: resizeEdges
- };
- }
-
- return null;
- }
-
- // Check if action is enabled globally and the current target supports it
- // If so, return the validated action. Otherwise, return null
- function validateAction (action, interactable) {
- if (!isObject(action)) { return null; }
-
- var actionName = action.name,
- options = interactable.options;
-
- if (( (actionName === 'resize' && options.resize.enabled )
- || (actionName === 'drag' && options.drag.enabled )
- || (actionName === 'gesture' && options.gesture.enabled))
- && actionIsEnabled[actionName]) {
-
- if (actionName === 'resize' || actionName === 'resizeyx') {
- actionName = 'resizexy';
- }
-
- return action;
- }
- return null;
- }
-
- var listeners = {},
- interactionListeners = [
- 'dragStart', 'dragMove', 'resizeStart', 'resizeMove', 'gestureStart', 'gestureMove',
- 'pointerOver', 'pointerOut', 'pointerHover', 'selectorDown',
- 'pointerDown', 'pointerMove', 'pointerUp', 'pointerCancel', 'pointerEnd',
- 'addPointer', 'removePointer', 'recordPointer', 'autoScrollMove'
- ];
-
- for (var i = 0, len = interactionListeners.length; i < len; i++) {
- var name = interactionListeners[i];
-
- listeners[name] = doOnInteractions(name);
- }
-
- // bound to the interactable context when a DOM event
- // listener is added to a selector interactable
- function delegateListener (event, useCapture) {
- var fakeEvent = {},
- delegated = delegatedEvents[event.type],
- eventTarget = getActualElement(event.path
- ? event.path[0]
- : event.target),
- element = eventTarget;
-
- useCapture = useCapture? true: false;
-
- // duplicate the event so that currentTarget can be changed
- for (var prop in event) {
- fakeEvent[prop] = event[prop];
- }
-
- fakeEvent.originalEvent = event;
- fakeEvent.preventDefault = preventOriginalDefault;
-
- // climb up document tree looking for selector matches
- while (isElement(element)) {
- for (var i = 0; i < delegated.selectors.length; i++) {
- var selector = delegated.selectors[i],
- context = delegated.contexts[i];
-
- if (matchesSelector(element, selector)
- && nodeContains(context, eventTarget)
- && nodeContains(context, element)) {
-
- var listeners = delegated.listeners[i];
-
- fakeEvent.currentTarget = element;
-
- for (var j = 0; j < listeners.length; j++) {
- if (listeners[j][1] === useCapture) {
- listeners[j][0](fakeEvent);
- }
- }
- }
- }
-
- element = parentElement(element);
- }
- }
-
- function delegateUseCapture (event) {
- return delegateListener.call(this, event, true);
- }
-
- interactables.indexOfElement = function indexOfElement (element, context) {
- context = context || document;
-
- for (var i = 0; i < this.length; i++) {
- var interactable = this[i];
-
- if ((interactable.selector === element
- && (interactable._context === context))
- || (!interactable.selector && interactable._element === element)) {
-
- return i;
- }
- }
- return -1;
- };
-
- interactables.get = function interactableGet (element, options) {
- return this[this.indexOfElement(element, options && options.context)];
- };
-
- interactables.forEachSelector = function (callback) {
- for (var i = 0; i < this.length; i++) {
- var interactable = this[i];
-
- if (!interactable.selector) {
- continue;
- }
-
- var ret = callback(interactable, interactable.selector, interactable._context, i, this);
-
- if (ret !== undefined) {
- return ret;
- }
- }
- };
-
- /*\
- * interact
- [ method ]
- *
- * The methods of this variable can be used to set elements as
- * interactables and also to change various default settings.
- *
- * Calling it as a function and passing an element or a valid CSS selector
- * string returns an Interactable object which has various methods to
- * configure it.
- *
- - element (Element | string) The HTML or SVG Element to interact with or CSS selector
- = (object) An @Interactable
- *
- > Usage
- | interact(document.getElementById('draggable')).draggable(true);
- |
- | var rectables = interact('rect');
- | rectables
- | .gesturable(true)
- | .on('gesturemove', function (event) {
- | // something cool...
- | })
- | .autoScroll(true);
- \*/
- function interact (element, options) {
- return interactables.get(element, options) || new Interactable(element, options);
- }
-
- /*\
- * Interactable
- [ property ]
- **
- * Object type returned by @interact
- \*/
- function Interactable (element, options) {
- this._element = element;
- this._iEvents = this._iEvents || {};
-
- var _window;
-
- if (trySelector(element)) {
- this.selector = element;
-
- var context = options && options.context;
-
- _window = context? getWindow(context) : window;
-
- if (context && (_window.Node
- ? context instanceof _window.Node
- : (isElement(context) || context === _window.document))) {
-
- this._context = context;
- }
- }
- else {
- _window = getWindow(element);
-
- if (isElement(element, _window)) {
-
- if (PointerEvent) {
- events.add(this._element, pEventTypes.down, listeners.pointerDown );
- events.add(this._element, pEventTypes.move, listeners.pointerHover);
- }
- else {
- events.add(this._element, 'mousedown' , listeners.pointerDown );
- events.add(this._element, 'mousemove' , listeners.pointerHover);
- events.add(this._element, 'touchstart', listeners.pointerDown );
- events.add(this._element, 'touchmove' , listeners.pointerHover);
- }
- }
- }
-
- this._doc = _window.document;
-
- if (!contains(documents, this._doc)) {
- listenToDocument(this._doc);
- }
-
- interactables.push(this);
-
- this.set(options);
- }
-
- Interactable.prototype = {
- setOnEvents: function (action, phases) {
- if (action === 'drop') {
- if (isFunction(phases.ondrop) ) { this.ondrop = phases.ondrop ; }
- if (isFunction(phases.ondropactivate) ) { this.ondropactivate = phases.ondropactivate ; }
- if (isFunction(phases.ondropdeactivate)) { this.ondropdeactivate = phases.ondropdeactivate; }
- if (isFunction(phases.ondragenter) ) { this.ondragenter = phases.ondragenter ; }
- if (isFunction(phases.ondragleave) ) { this.ondragleave = phases.ondragleave ; }
- if (isFunction(phases.ondropmove) ) { this.ondropmove = phases.ondropmove ; }
- }
- else {
- action = 'on' + action;
-
- if (isFunction(phases.onstart) ) { this[action + 'start' ] = phases.onstart ; }
- if (isFunction(phases.onmove) ) { this[action + 'move' ] = phases.onmove ; }
- if (isFunction(phases.onend) ) { this[action + 'end' ] = phases.onend ; }
- if (isFunction(phases.oninertiastart)) { this[action + 'inertiastart' ] = phases.oninertiastart ; }
- }
-
- return this;
- },
-
- /*\
- * Interactable.draggable
- [ method ]
- *
- * Gets or sets whether drag actions can be performed on the
- * Interactable
- *
- = (boolean) Indicates if this can be the target of drag events
- | var isDraggable = interact('ul li').draggable();
- * or
- - options (boolean | object) #optional true/false or An object with event listeners to be fired on drag events (object makes the Interactable draggable)
- = (object) This Interactable
- | interact(element).draggable({
- | onstart: function (event) {},
- | onmove : function (event) {},
- | onend : function (event) {},
- |
- | // the axis in which the first movement must be
- | // for the drag sequence to start
- | // 'xy' by default - any direction
- | axis: 'x' || 'y' || 'xy',
- |
- | // max number of drags that can happen concurrently
- | // with elements of this Interactable. Infinity by default
- | max: Infinity,
- |
- | // max number of drags that can target the same element+Interactable
- | // 1 by default
- | maxPerElement: 2
- | });
- \*/
- draggable: function (options) {
- if (isObject(options)) {
- this.options.drag.enabled = options.enabled === false? false: true;
- this.setPerAction('drag', options);
- this.setOnEvents('drag', options);
-
- if (/^x$|^y$|^xy$/.test(options.axis)) {
- this.options.drag.axis = options.axis;
- }
- else if (options.axis === null) {
- delete this.options.drag.axis;
- }
-
- return this;
- }
-
- if (isBool(options)) {
- this.options.drag.enabled = options;
-
- return this;
- }
-
- return this.options.drag;
- },
-
- setPerAction: function (action, options) {
- // for all the default per-action options
- for (var option in options) {
- // if this option exists for this action
- if (option in defaultOptions[action]) {
- // if the option in the options arg is an object value
- if (isObject(options[option])) {
- // duplicate the object
- this.options[action][option] = extend(this.options[action][option] || {}, options[option]);
-
- if (isObject(defaultOptions.perAction[option]) && 'enabled' in defaultOptions.perAction[option]) {
- this.options[action][option].enabled = options[option].enabled === false? false : true;
- }
- }
- else if (isBool(options[option]) && isObject(defaultOptions.perAction[option])) {
- this.options[action][option].enabled = options[option];
- }
- else if (options[option] !== undefined) {
- // or if it's not undefined, do a plain assignment
- this.options[action][option] = options[option];
- }
- }
- }
- },
-
- /*\
- * Interactable.dropzone
- [ method ]
- *
- * Returns or sets whether elements can be dropped onto this
- * Interactable to trigger drop events
- *
- * Dropzones can receive the following events:
- * - `dropactivate` and `dropdeactivate` when an acceptable drag starts and ends
- * - `dragenter` and `dragleave` when a draggable enters and leaves the dropzone
- * - `dragmove` when a draggable that has entered the dropzone is moved
- * - `drop` when a draggable is dropped into this dropzone
- *
- * Use the `accept` option to allow only elements that match the given CSS selector or element.
- *
- * Use the `overlap` option to set how drops are checked for. The allowed values are:
- * - `'pointer'`, the pointer must be over the dropzone (default)
- * - `'center'`, the draggable element's center must be over the dropzone
- * - a number from 0-1 which is the `(intersection area) / (draggable area)`.
- * e.g. `0.5` for drop to happen when half of the area of the
- * draggable is over the dropzone
- *
- - options (boolean | object | null) #optional The new value to be set.
- | interact('.drop').dropzone({
- | accept: '.can-drop' || document.getElementById('single-drop'),
- | overlap: 'pointer' || 'center' || zeroToOne
- | }
- = (boolean | object) The current setting or this Interactable
- \*/
- dropzone: function (options) {
- if (isObject(options)) {
- this.options.drop.enabled = options.enabled === false? false: true;
- this.setOnEvents('drop', options);
- this.accept(options.accept);
-
- if (/^(pointer|center)$/.test(options.overlap)) {
- this.options.drop.overlap = options.overlap;
- }
- else if (isNumber(options.overlap)) {
- this.options.drop.overlap = Math.max(Math.min(1, options.overlap), 0);
- }
-
- return this;
- }
-
- if (isBool(options)) {
- this.options.drop.enabled = options;
-
- return this;
- }
-
- return this.options.drop;
- },
-
- dropCheck: function (pointer, draggable, draggableElement, dropElement, rect) {
- var dropped = false;
-
- // if the dropzone has no rect (eg. display: none)
- // call the custom dropChecker or just return false
- if (!(rect = rect || this.getRect(dropElement))) {
- return (this.options.dropChecker
- ? this.options.dropChecker(pointer, dropped, this, dropElement, draggable, draggableElement)
- : false);
- }
-
- var dropOverlap = this.options.drop.overlap;
-
- if (dropOverlap === 'pointer') {
- var page = getPageXY(pointer),
- origin = getOriginXY(draggable, draggableElement),
- horizontal,
- vertical;
-
- page.x += origin.x;
- page.y += origin.y;
-
- horizontal = (page.x > rect.left) && (page.x < rect.right);
- vertical = (page.y > rect.top ) && (page.y < rect.bottom);
-
- dropped = horizontal && vertical;
- }
-
- var dragRect = draggable.getRect(draggableElement);
-
- if (dropOverlap === 'center') {
- var cx = dragRect.left + dragRect.width / 2,
- cy = dragRect.top + dragRect.height / 2;
-
- dropped = cx >= rect.left && cx <= rect.right && cy >= rect.top && cy <= rect.bottom;
- }
-
- if (isNumber(dropOverlap)) {
- var overlapArea = (Math.max(0, Math.min(rect.right , dragRect.right ) - Math.max(rect.left, dragRect.left))
- * Math.max(0, Math.min(rect.bottom, dragRect.bottom) - Math.max(rect.top , dragRect.top ))),
- overlapRatio = overlapArea / (dragRect.width * dragRect.height);
-
- dropped = overlapRatio >= dropOverlap;
- }
-
- if (this.options.dropChecker) {
- dropped = this.options.dropChecker(pointer, dropped, this, dropElement, draggable, draggableElement);
- }
-
- return dropped;
- },
-
- /*\
- * Interactable.dropChecker
- [ method ]
- *
- * Gets or sets the function used to check if a dragged element is
- * over this Interactable. See @Interactable.dropCheck.
- *
- - checker (function) #optional
- * The checker is a function which takes a mouseUp/touchEnd event as a
- * parameter and returns true or false to indicate if the the current
- * draggable can be dropped into this Interactable
- *
- - checker (function) The function that will be called when checking for a drop
- * The checker function takes the following arguments:
- *
- - pointer (MouseEvent | PointerEvent | Touch) The pointer/event that ends a drag
- - dropped (boolean) The value from the default drop check
- - dropzone (Interactable) The dropzone interactable
- - dropElement (Element) The dropzone element
- - draggable (Interactable) The Interactable being dragged
- - draggableElement (Element) The actual element that's being dragged
- *
- = (Function | Interactable) The checker function or this Interactable
- \*/
- dropChecker: function (checker) {
- if (isFunction(checker)) {
- this.options.dropChecker = checker;
-
- return this;
- }
- if (checker === null) {
- delete this.options.getRect;
-
- return this;
- }
-
- return this.options.dropChecker;
- },
-
- /*\
- * Interactable.accept
- [ method ]
- *
- * Deprecated. add an `accept` property to the options object passed to
- * @Interactable.dropzone instead.
- *
- * Gets or sets the Element or CSS selector match that this
- * Interactable accepts if it is a dropzone.
- *
- - newValue (Element | string | null) #optional
- * If it is an Element, then only that element can be dropped into this dropzone.
- * If it is a string, the element being dragged must match it as a selector.
- * If it is null, the accept options is cleared - it accepts any element.
- *
- = (string | Element | null | Interactable) The current accept option if given `undefined` or this Interactable
- \*/
- accept: function (newValue) {
- if (isElement(newValue)) {
- this.options.drop.accept = newValue;
-
- return this;
- }
-
- // test if it is a valid CSS selector
- if (trySelector(newValue)) {
- this.options.drop.accept = newValue;
-
- return this;
- }
-
- if (newValue === null) {
- delete this.options.drop.accept;
-
- return this;
- }
-
- return this.options.drop.accept;
- },
-
- /*\
- * Interactable.resizable
- [ method ]
- *
- * Gets or sets whether resize actions can be performed on the
- * Interactable
- *
- = (boolean) Indicates if this can be the target of resize elements
- | var isResizeable = interact('input[type=text]').resizable();
- * or
- - options (boolean | object) #optional true/false or An object with event listeners to be fired on resize events (object makes the Interactable resizable)
- = (object) This Interactable
- | interact(element).resizable({
- | onstart: function (event) {},
- | onmove : function (event) {},
- | onend : function (event) {},
- |
- | edges: {
- | top : true, // Use pointer coords to check for resize.
- | left : false, // Disable resizing from left edge.
- | bottom: '.resize-s',// Resize if pointer target matches selector
- | right : handleEl // Resize if pointer target is the given Element
- | },
- |
- | // a value of 'none' will limit the resize rect to a minimum of 0x0
- | // 'negate' will allow the rect to have negative width/height
- | // 'reposition' will keep the width/height positive by swapping
- | // the top and bottom edges and/or swapping the left and right edges
- | invert: 'none' || 'negate' || 'reposition'
- |
- | // limit multiple resizes.
- | // See the explanation in the @Interactable.draggable example
- | max: Infinity,
- | maxPerElement: 1,
- | });
- \*/
- resizable: function (options) {
- if (isObject(options)) {
- this.options.resize.enabled = options.enabled === false? false: true;
- this.setPerAction('resize', options);
- this.setOnEvents('resize', options);
-
- if (/^x$|^y$|^xy$/.test(options.axis)) {
- this.options.resize.axis = options.axis;
- }
- else if (options.axis === null) {
- this.options.resize.axis = defaultOptions.resize.axis;
- }
-
- if (isBool(options.square)) {
- this.options.resize.square = options.square;
- }
-
- return this;
- }
- if (isBool(options)) {
- this.options.resize.enabled = options;
-
- return this;
- }
- return this.options.resize;
- },
-
- /*\
- * Interactable.squareResize
- [ method ]
- *
- * Deprecated. Add a `square: true || false` property to @Interactable.resizable instead
- *
- * Gets or sets whether resizing is forced 1:1 aspect
- *
- = (boolean) Current setting
- *
- * or
- *
- - newValue (boolean) #optional
- = (object) this Interactable
- \*/
- squareResize: function (newValue) {
- if (isBool(newValue)) {
- this.options.resize.square = newValue;
-
- return this;
- }
-
- if (newValue === null) {
- delete this.options.resize.square;
-
- return this;
- }
-
- return this.options.resize.square;
- },
-
- /*\
- * Interactable.gesturable
- [ method ]
- *
- * Gets or sets whether multitouch gestures can be performed on the
- * Interactable's element
- *
- = (boolean) Indicates if this can be the target of gesture events
- | var isGestureable = interact(element).gesturable();
- * or
- - options (boolean | object) #optional true/false or An object with event listeners to be fired on gesture events (makes the Interactable gesturable)
- = (object) this Interactable
- | interact(element).gesturable({
- | onstart: function (event) {},
- | onmove : function (event) {},
- | onend : function (event) {},
- |
- | // limit multiple gestures.
- | // See the explanation in @Interactable.draggable example
- | max: Infinity,
- | maxPerElement: 1,
- | });
- \*/
- gesturable: function (options) {
- if (isObject(options)) {
- this.options.gesture.enabled = options.enabled === false? false: true;
- this.setPerAction('gesture', options);
- this.setOnEvents('gesture', options);
-
- return this;
- }
-
- if (isBool(options)) {
- this.options.gesture.enabled = options;
-
- return this;
- }
-
- return this.options.gesture;
- },
-
- /*\
- * Interactable.autoScroll
- [ method ]
- **
- * Deprecated. Add an `autoscroll` property to the options object
- * passed to @Interactable.draggable or @Interactable.resizable instead.
- *
- * Returns or sets whether dragging and resizing near the edges of the
- * window/container trigger autoScroll for this Interactable
- *
- = (object) Object with autoScroll properties
- *
- * or
- *
- - options (object | boolean) #optional
- * options can be:
- * - an object with margin, distance and interval properties,
- * - true or false to enable or disable autoScroll or
- = (Interactable) this Interactable
- \*/
- autoScroll: function (options) {
- if (isObject(options)) {
- options = extend({ actions: ['drag', 'resize']}, options);
- }
- else if (isBool(options)) {
- options = { actions: ['drag', 'resize'], enabled: options };
- }
-
- return this.setOptions('autoScroll', options);
- },
-
- /*\
- * Interactable.snap
- [ method ]
- **
- * Deprecated. Add a `snap` property to the options object passed
- * to @Interactable.draggable or @Interactable.resizable instead.
- *
- * Returns or sets if and how action coordinates are snapped. By
- * default, snapping is relative to the pointer coordinates. You can
- * change this by setting the
- * [`elementOrigin`](https://github.com/taye/interact.js/pull/72).
- **
- = (boolean | object) `false` if snap is disabled; object with snap properties if snap is enabled
- **
- * or
- **
- - options (object | boolean | null) #optional
- = (Interactable) this Interactable
- > Usage
- | interact(document.querySelector('#thing')).snap({
- | targets: [
- | // snap to this specific point
- | {
- | x: 100,
- | y: 100,
- | range: 25
- | },
- | // give this function the x and y page coords and snap to the object returned
- | function (x, y) {
- | return {
- | x: x,
- | y: (75 + 50 * Math.sin(x * 0.04)),
- | range: 40
- | };
- | },
- | // create a function that snaps to a grid
- | interact.createSnapGrid({
- | x: 50,
- | y: 50,
- | range: 10, // optional
- | offset: { x: 5, y: 10 } // optional
- | })
- | ],
- | // do not snap during normal movement.
- | // Instead, trigger only one snapped move event
- | // immediately before the end event.
- | endOnly: true,
- |
- | relativePoints: [
- | { x: 0, y: 0 }, // snap relative to the top left of the element
- | { x: 1, y: 1 }, // and also to the bottom right
- | ],
- |
- | // offset the snap target coordinates
- | // can be an object with x/y or 'startCoords'
- | offset: { x: 50, y: 50 }
- | }
- | });
- \*/
- snap: function (options) {
- var ret = this.setOptions('snap', options);
-
- if (ret === this) { return this; }
-
- return ret.drag;
- },
-
- setOptions: function (option, options) {
- var actions = options && isArray(options.actions)
- ? options.actions
- : ['drag'];
-
- var i;
-
- if (isObject(options) || isBool(options)) {
- for (i = 0; i < actions.length; i++) {
- var action = /resize/.test(actions[i])? 'resize' : actions[i];
-
- if (!isObject(this.options[action])) { continue; }
-
- var thisOption = this.options[action][option];
-
- if (isObject(options)) {
- extend(thisOption, options);
- thisOption.enabled = options.enabled === false? false: true;
-
- if (option === 'snap') {
- if (thisOption.mode === 'grid') {
- thisOption.targets = [
- interact.createSnapGrid(extend({
- offset: thisOption.gridOffset || { x: 0, y: 0 }
- }, thisOption.grid || {}))
- ];
- }
- else if (thisOption.mode === 'anchor') {
- thisOption.targets = thisOption.anchors;
- }
- else if (thisOption.mode === 'path') {
- thisOption.targets = thisOption.paths;
- }
-
- if ('elementOrigin' in options) {
- thisOption.relativePoints = [options.elementOrigin];
- }
- }
- }
- else if (isBool(options)) {
- thisOption.enabled = options;
- }
- }
-
- return this;
- }
-
- var ret = {},
- allActions = ['drag', 'resize', 'gesture'];
-
- for (i = 0; i < allActions.length; i++) {
- if (option in defaultOptions[allActions[i]]) {
- ret[allActions[i]] = this.options[allActions[i]][option];
- }
- }
-
- return ret;
- },
-
-
- /*\
- * Interactable.inertia
- [ method ]
- **
- * Deprecated. Add an `inertia` property to the options object passed
- * to @Interactable.draggable or @Interactable.resizable instead.
- *
- * Returns or sets if and how events continue to run after the pointer is released
- **
- = (boolean | object) `false` if inertia is disabled; `object` with inertia properties if inertia is enabled
- **
- * or
- **
- - options (object | boolean | null) #optional
- = (Interactable) this Interactable
- > Usage
- | // enable and use default settings
- | interact(element).inertia(true);
- |
- | // enable and use custom settings
- | interact(element).inertia({
- | // value greater than 0
- | // high values slow the object down more quickly
- | resistance : 16,
- |
- | // the minimum launch speed (pixels per second) that results in inertia start
- | minSpeed : 200,
- |
- | // inertia will stop when the object slows down to this speed
- | endSpeed : 20,
- |
- | // boolean; should actions be resumed when the pointer goes down during inertia
- | allowResume : true,
- |
- | // boolean; should the jump when resuming from inertia be ignored in event.dx/dy
- | zeroResumeDelta: false,
- |
- | // if snap/restrict are set to be endOnly and inertia is enabled, releasing
- | // the pointer without triggering inertia will animate from the release
- | // point to the snaped/restricted point in the given amount of time (ms)
- | smoothEndDuration: 300,
- |
- | // an array of action types that can have inertia (no gesture)
- | actions : ['drag', 'resize']
- | });
- |
- | // reset custom settings and use all defaults
- | interact(element).inertia(null);
- \*/
- inertia: function (options) {
- var ret = this.setOptions('inertia', options);
-
- if (ret === this) { return this; }
-
- return ret.drag;
- },
-
- getAction: function (pointer, interaction, element) {
- var action = this.defaultActionChecker(pointer, interaction, element);
-
- if (this.options.actionChecker) {
- return this.options.actionChecker(pointer, action, this, element, interaction);
- }
-
- return action;
- },
-
- defaultActionChecker: defaultActionChecker,
-
- /*\
- * Interactable.actionChecker
- [ method ]
- *
- * Gets or sets the function used to check action to be performed on
- * pointerDown
- *
- - checker (function | null) #optional A function which takes a pointer event, defaultAction string, interactable, element and interaction as parameters and returns an object with name property 'drag' 'resize' or 'gesture' and optionally an `edges` object with boolean 'top', 'left', 'bottom' and right props.
- = (Function | Interactable) The checker function or this Interactable
- *
- | interact('.resize-horiz').actionChecker(function (defaultAction, interactable) {
- | return {
- | // resize from the top and right edges
- | name: 'resize',
- | edges: { top: true, right: true }
- | };
- | });
- \*/
- actionChecker: function (checker) {
- if (isFunction(checker)) {
- this.options.actionChecker = checker;
-
- return this;
- }
-
- if (checker === null) {
- delete this.options.actionChecker;
-
- return this;
- }
-
- return this.options.actionChecker;
- },
-
- /*\
- * Interactable.getRect
- [ method ]
- *
- * The default function to get an Interactables bounding rect. Can be
- * overridden using @Interactable.rectChecker.
- *
- - element (Element) #optional The element to measure.
- = (object) The object's bounding rectangle.
- o {
- o top : 0,
- o left : 0,
- o bottom: 0,
- o right : 0,
- o width : 0,
- o height: 0
- o }
- \*/
- getRect: function rectCheck (element) {
- element = element || this._element;
-
- if (this.selector && !(isElement(element))) {
- element = this._context.querySelector(this.selector);
- }
-
- return getElementRect(element);
- },
-
- /*\
- * Interactable.rectChecker
- [ method ]
- *
- * Returns or sets the function used to calculate the interactable's
- * element's rectangle
- *
- - checker (function) #optional A function which returns this Interactable's bounding rectangle. See @Interactable.getRect
- = (function | object) The checker function or this Interactable
- \*/
- rectChecker: function (checker) {
- if (isFunction(checker)) {
- this.getRect = checker;
-
- return this;
- }
-
- if (checker === null) {
- delete this.options.getRect;
-
- return this;
- }
-
- return this.getRect;
- },
-
- /*\
- * Interactable.styleCursor
- [ method ]
- *
- * Returns or sets whether the action that would be performed when the
- * mouse on the element are checked on `mousemove` so that the cursor
- * may be styled appropriately
- *
- - newValue (boolean) #optional
- = (boolean | Interactable) The current setting or this Interactable
- \*/
- styleCursor: function (newValue) {
- if (isBool(newValue)) {
- this.options.styleCursor = newValue;
-
- return this;
- }
-
- if (newValue === null) {
- delete this.options.styleCursor;
-
- return this;
- }
-
- return this.options.styleCursor;
- },
-
- /*\
- * Interactable.preventDefault
- [ method ]
- *
- * Returns or sets whether to prevent the browser's default behaviour
- * in response to pointer events. Can be set to:
- * - `'always'` to always prevent
- * - `'never'` to never prevent
- * - `'auto'` to let interact.js try to determine what would be best
- *
- - newValue (string) #optional `true`, `false` or `'auto'`
- = (string | Interactable) The current setting or this Interactable
- \*/
- preventDefault: function (newValue) {
- if (/^(always|never|auto)$/.test(newValue)) {
- this.options.preventDefault = newValue;
- return this;
- }
-
- if (isBool(newValue)) {
- this.options.preventDefault = newValue? 'always' : 'never';
- return this;
- }
-
- return this.options.preventDefault;
- },
-
- /*\
- * Interactable.origin
- [ method ]
- *
- * Gets or sets the origin of the Interactable's element. The x and y
- * of the origin will be subtracted from action event coordinates.
- *
- - origin (object | string) #optional An object eg. { x: 0, y: 0 } or string 'parent', 'self' or any CSS selector
- * OR
- - origin (Element) #optional An HTML or SVG Element whose rect will be used
- **
- = (object) The current origin or this Interactable
- \*/
- origin: function (newValue) {
- if (trySelector(newValue)) {
- this.options.origin = newValue;
- return this;
- }
- else if (isObject(newValue)) {
- this.options.origin = newValue;
- return this;
- }
-
- return this.options.origin;
- },
-
- /*\
- * Interactable.deltaSource
- [ method ]
- *
- * Returns or sets the mouse coordinate types used to calculate the
- * movement of the pointer.
- *
- - newValue (string) #optional Use 'client' if you will be scrolling while interacting; Use 'page' if you want autoScroll to work
- = (string | object) The current deltaSource or this Interactable
- \*/
- deltaSource: function (newValue) {
- if (newValue === 'page' || newValue === 'client') {
- this.options.deltaSource = newValue;
-
- return this;
- }
-
- return this.options.deltaSource;
- },
-
- /*\
- * Interactable.restrict
- [ method ]
- **
- * Deprecated. Add a `restrict` property to the options object passed to
- * @Interactable.draggable, @Interactable.resizable or @Interactable.gesturable instead.
- *
- * Returns or sets the rectangles within which actions on this
- * interactable (after snap calculations) are restricted. By default,
- * restricting is relative to the pointer coordinates. You can change
- * this by setting the
- * [`elementRect`](https://github.com/taye/interact.js/pull/72).
- **
- - options (object) #optional an object with keys drag, resize, and/or gesture whose values are rects, Elements, CSS selectors, or 'parent' or 'self'
- = (object) The current restrictions object or this Interactable
- **
- | interact(element).restrict({
- | // the rect will be `interact.getElementRect(element.parentNode)`
- | drag: element.parentNode,
- |
- | // x and y are relative to the the interactable's origin
- | resize: { x: 100, y: 100, width: 200, height: 200 }
- | })
- |
- | interact('.draggable').restrict({
- | // the rect will be the selected element's parent
- | drag: 'parent',
- |
- | // do not restrict during normal movement.
- | // Instead, trigger only one restricted move event
- | // immediately before the end event.
- | endOnly: true,
- |
- | // https://github.com/taye/interact.js/pull/72#issue-41813493
- | elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
- | });
- \*/
- restrict: function (options) {
- if (!isObject(options)) {
- return this.setOptions('restrict', options);
- }
-
- var actions = ['drag', 'resize', 'gesture'],
- ret;
-
- for (var i = 0; i < actions.length; i++) {
- var action = actions[i];
-
- if (action in options) {
- var perAction = extend({
- actions: [action],
- restriction: options[action]
- }, options);
-
- ret = this.setOptions('restrict', perAction);
- }
- }
-
- return ret;
- },
-
- /*\
- * Interactable.context
- [ method ]
- *
- * Gets the selector context Node of the Interactable. The default is `window.document`.
- *
- = (Node) The context Node of this Interactable
- **
- \*/
- context: function () {
- return this._context;
- },
-
- _context: document,
-
- /*\
- * Interactable.ignoreFrom
- [ method ]
- *
- * If the target of the `mousedown`, `pointerdown` or `touchstart`
- * event or any of it's parents match the given CSS selector or
- * Element, no drag/resize/gesture is started.
- *
- - newValue (string | Element | null) #optional a CSS selector string, an Element or `null` to not ignore any elements
- = (string | Element | object) The current ignoreFrom value or this Interactable
- **
- | interact(element, { ignoreFrom: document.getElementById('no-action') });
- | // or
- | interact(element).ignoreFrom('input, textarea, a');
- \*/
- ignoreFrom: function (newValue) {
- if (trySelector(newValue)) { // CSS selector to match event.target
- this.options.ignoreFrom = newValue;
- return this;
- }
-
- if (isElement(newValue)) { // specific element
- this.options.ignoreFrom = newValue;
- return this;
- }
-
- return this.options.ignoreFrom;
- },
-
- /*\
- * Interactable.allowFrom
- [ method ]
- *
- * A drag/resize/gesture is started only If the target of the
- * `mousedown`, `pointerdown` or `touchstart` event or any of it's
- * parents match the given CSS selector or Element.
- *
- - newValue (string | Element | null) #optional a CSS selector string, an Element or `null` to allow from any element
- = (string | Element | object) The current allowFrom value or this Interactable
- **
- | interact(element, { allowFrom: document.getElementById('drag-handle') });
- | // or
- | interact(element).allowFrom('.handle');
- \*/
- allowFrom: function (newValue) {
- if (trySelector(newValue)) { // CSS selector to match event.target
- this.options.allowFrom = newValue;
- return this;
- }
-
- if (isElement(newValue)) { // specific element
- this.options.allowFrom = newValue;
- return this;
- }
-
- return this.options.allowFrom;
- },
-
- /*\
- * Interactable.element
- [ method ]
- *
- * If this is not a selector Interactable, it returns the element this
- * interactable represents
- *
- = (Element) HTML / SVG Element
- \*/
- element: function () {
- return this._element;
- },
-
- /*\
- * Interactable.fire
- [ method ]
- *
- * Calls listeners for the given InteractEvent type bound globally
- * and directly to this Interactable
- *
- - iEvent (InteractEvent) The InteractEvent object to be fired on this Interactable
- = (Interactable) this Interactable
- \*/
- fire: function (iEvent) {
- if (!(iEvent && iEvent.type) || !contains(eventTypes, iEvent.type)) {
- return this;
- }
-
- var listeners,
- i,
- len,
- onEvent = 'on' + iEvent.type,
- funcName = '';
-
- // Interactable#on() listeners
- if (iEvent.type in this._iEvents) {
- listeners = this._iEvents[iEvent.type];
-
- for (i = 0, len = listeners.length; i < len && !iEvent.immediatePropagationStopped; i++) {
- funcName = listeners[i].name;
- listeners[i](iEvent);
- }
- }
-
- // interactable.onevent listener
- if (isFunction(this[onEvent])) {
- funcName = this[onEvent].name;
- this[onEvent](iEvent);
- }
-
- // interact.on() listeners
- if (iEvent.type in globalEvents && (listeners = globalEvents[iEvent.type])) {
-
- for (i = 0, len = listeners.length; i < len && !iEvent.immediatePropagationStopped; i++) {
- funcName = listeners[i].name;
- listeners[i](iEvent);
- }
- }
-
- return this;
- },
-
- /*\
- * Interactable.on
- [ method ]
- *
- * Binds a listener for an InteractEvent or DOM event.
- *
- - eventType (string | array | object) The types of events to listen for
- - listener (function) The function to be called on the given event(s)
- - useCapture (boolean) #optional useCapture flag for addEventListener
- = (object) This Interactable
- \*/
- on: function (eventType, listener, useCapture) {
- var i;
-
- if (isString(eventType) && eventType.search(' ') !== -1) {
- eventType = eventType.trim().split(/ +/);
- }
-
- if (isArray(eventType)) {
- for (i = 0; i < eventType.length; i++) {
- this.on(eventType[i], listener, useCapture);
- }
-
- return this;
- }
-
- if (isObject(eventType)) {
- for (var prop in eventType) {
- this.on(prop, eventType[prop], listener);
- }
-
- return this;
- }
-
- if (eventType === 'wheel') {
- eventType = wheelEvent;
- }
-
- // convert to boolean
- useCapture = useCapture? true: false;
-
- if (contains(eventTypes, eventType)) {
- // if this type of event was never bound to this Interactable
- if (!(eventType in this._iEvents)) {
- this._iEvents[eventType] = [listener];
- }
- else {
- this._iEvents[eventType].push(listener);
- }
- }
- // delegated event for selector
- else if (this.selector) {
- if (!delegatedEvents[eventType]) {
- delegatedEvents[eventType] = {
- selectors: [],
- contexts : [],
- listeners: []
- };
-
- // add delegate listener functions
- for (i = 0; i < documents.length; i++) {
- events.add(documents[i], eventType, delegateListener);
- events.add(documents[i], eventType, delegateUseCapture, true);
- }
- }
-
- var delegated = delegatedEvents[eventType],
- index;
-
- for (index = delegated.selectors.length - 1; index >= 0; index--) {
- if (delegated.selectors[index] === this.selector
- && delegated.contexts[index] === this._context) {
- break;
- }
- }
-
- if (index === -1) {
- index = delegated.selectors.length;
-
- delegated.selectors.push(this.selector);
- delegated.contexts .push(this._context);
- delegated.listeners.push([]);
- }
-
- // keep listener and useCapture flag
- delegated.listeners[index].push([listener, useCapture]);
- }
- else {
- events.add(this._element, eventType, listener, useCapture);
- }
-
- return this;
- },
-
- /*\
- * Interactable.off
- [ method ]
- *
- * Removes an InteractEvent or DOM event listener
- *
- - eventType (string | array | object) The types of events that were listened for
- - listener (function) The listener function to be removed
- - useCapture (boolean) #optional useCapture flag for removeEventListener
- = (object) This Interactable
- \*/
- off: function (eventType, listener, useCapture) {
- var i;
-
- if (isString(eventType) && eventType.search(' ') !== -1) {
- eventType = eventType.trim().split(/ +/);
- }
-
- if (isArray(eventType)) {
- for (i = 0; i < eventType.length; i++) {
- this.off(eventType[i], listener, useCapture);
- }
-
- return this;
- }
-
- if (isObject(eventType)) {
- for (var prop in eventType) {
- this.off(prop, eventType[prop], listener);
- }
-
- return this;
- }
-
- var eventList,
- index = -1;
-
- // convert to boolean
- useCapture = useCapture? true: false;
-
- if (eventType === 'wheel') {
- eventType = wheelEvent;
- }
-
- // if it is an action event type
- if (contains(eventTypes, eventType)) {
- eventList = this._iEvents[eventType];
-
- if (eventList && (index = indexOf(eventList, listener)) !== -1) {
- this._iEvents[eventType].splice(index, 1);
- }
- }
- // delegated event
- else if (this.selector) {
- var delegated = delegatedEvents[eventType],
- matchFound = false;
-
- if (!delegated) { return this; }
-
- // count from last index of delegated to 0
- for (index = delegated.selectors.length - 1; index >= 0; index--) {
- // look for matching selector and context Node
- if (delegated.selectors[index] === this.selector
- && delegated.contexts[index] === this._context) {
-
- var listeners = delegated.listeners[index];
-
- // each item of the listeners array is an array: [function, useCaptureFlag]
- for (i = listeners.length - 1; i >= 0; i--) {
- var fn = listeners[i][0],
- useCap = listeners[i][1];
-
- // check if the listener functions and useCapture flags match
- if (fn === listener && useCap === useCapture) {
- // remove the listener from the array of listeners
- listeners.splice(i, 1);
-
- // if all listeners for this interactable have been removed
- // remove the interactable from the delegated arrays
- if (!listeners.length) {
- delegated.selectors.splice(index, 1);
- delegated.contexts .splice(index, 1);
- delegated.listeners.splice(index, 1);
-
- // remove delegate function from context
- events.remove(this._context, eventType, delegateListener);
- events.remove(this._context, eventType, delegateUseCapture, true);
-
- // remove the arrays if they are empty
- if (!delegated.selectors.length) {
- delegatedEvents[eventType] = null;
- }
- }
-
- // only remove one listener
- matchFound = true;
- break;
- }
- }
-
- if (matchFound) { break; }
- }
- }
- }
- // remove listener from this Interatable's element
- else {
- events.remove(this._element, eventType, listener, useCapture);
- }
-
- return this;
- },
-
- /*\
- * Interactable.set
- [ method ]
- *
- * Reset the options of this Interactable
- - options (object) The new settings to apply
- = (object) This Interactablw
- \*/
- set: function (options) {
- if (!isObject(options)) {
- options = {};
- }
-
- this.options = extend({}, defaultOptions.base);
-
- var i,
- actions = ['drag', 'drop', 'resize', 'gesture'],
- methods = ['draggable', 'dropzone', 'resizable', 'gesturable'],
- perActions = extend(extend({}, defaultOptions.perAction), options[action] || {});
-
- for (i = 0; i < actions.length; i++) {
- var action = actions[i];
-
- this.options[action] = extend({}, defaultOptions[action]);
-
- this.setPerAction(action, perActions);
-
- this[methods[i]](options[action]);
- }
-
- var settings = [
- 'accept', 'actionChecker', 'allowFrom', 'deltaSource',
- 'dropChecker', 'ignoreFrom', 'origin', 'preventDefault',
- 'rectChecker'
- ];
-
- for (i = 0, len = settings.length; i < len; i++) {
- var setting = settings[i];
-
- this.options[setting] = defaultOptions.base[setting];
-
- if (setting in options) {
- this[setting](options[setting]);
- }
- }
-
- return this;
- },
-
- /*\
- * Interactable.unset
- [ method ]
- *
- * Remove this interactable from the list of interactables and remove
- * it's drag, drop, resize and gesture capabilities
- *
- = (object) @interact
- \*/
- unset: function () {
- events.remove(this._element, 'all');
-
- if (!isString(this.selector)) {
- events.remove(this, 'all');
- if (this.options.styleCursor) {
- this._element.style.cursor = '';
- }
- }
- else {
- // remove delegated events
- for (var type in delegatedEvents) {
- var delegated = delegatedEvents[type];
-
- for (var i = 0; i < delegated.selectors.length; i++) {
- if (delegated.selectors[i] === this.selector
- && delegated.contexts[i] === this._context) {
-
- delegated.selectors.splice(i, 1);
- delegated.contexts .splice(i, 1);
- delegated.listeners.splice(i, 1);
-
- // remove the arrays if they are empty
- if (!delegated.selectors.length) {
- delegatedEvents[type] = null;
- }
- }
-
- events.remove(this._context, type, delegateListener);
- events.remove(this._context, type, delegateUseCapture, true);
-
- break;
- }
- }
- }
-
- this.dropzone(false);
-
- interactables.splice(indexOf(interactables, this), 1);
-
- return interact;
- }
- };
-
- function warnOnce (method, message) {
- var warned = false;
-
- return function () {
- if (!warned) {
- window.console.warn(message);
- warned = true;
- }
-
- return method.apply(this, arguments);
- };
- }
-
- Interactable.prototype.snap = warnOnce(Interactable.prototype.snap,
- 'Interactable#snap is deprecated. See the new documentation for snapping at http://interactjs.io/docs/snapping');
- Interactable.prototype.restrict = warnOnce(Interactable.prototype.restrict,
- 'Interactable#restrict is deprecated. See the new documentation for resticting at http://interactjs.io/docs/restriction');
- Interactable.prototype.inertia = warnOnce(Interactable.prototype.inertia,
- 'Interactable#inertia is deprecated. See the new documentation for inertia at http://interactjs.io/docs/inertia');
- Interactable.prototype.autoScroll = warnOnce(Interactable.prototype.autoScroll,
- 'Interactable#autoScroll is deprecated. See the new documentation for autoScroll at http://interactjs.io/docs/#autoscroll');
- Interactable.prototype.squareResize = warnOnce(Interactable.prototype.squareResize,
- 'Interactable#squareResize is deprecated. See http://interactjs.io/docs/#resize-square');
-
- /*\
- * interact.isSet
- [ method ]
- *
- * Check if an element has been set
- - element (Element) The Element being searched for
- = (boolean) Indicates if the element or CSS selector was previously passed to interact
- \*/
- interact.isSet = function(element, options) {
- return interactables.indexOfElement(element, options && options.context) !== -1;
- };
-
- /*\
- * interact.on
- [ method ]
- *
- * Adds a global listener for an InteractEvent or adds a DOM event to
- * `document`
- *
- - type (string | array | object) The types of events to listen for
- - listener (function) The function to be called on the given event(s)
- - useCapture (boolean) #optional useCapture flag for addEventListener
- = (object) interact
- \*/
- interact.on = function (type, listener, useCapture) {
- if (isString(type) && type.search(' ') !== -1) {
- type = type.trim().split(/ +/);
- }
-
- if (isArray(type)) {
- for (var i = 0; i < type.length; i++) {
- interact.on(type[i], listener, useCapture);
- }
-
- return interact;
- }
-
- if (isObject(type)) {
- for (var prop in type) {
- interact.on(prop, type[prop], listener);
- }
-
- return interact;
- }
-
- // if it is an InteractEvent type, add listener to globalEvents
- if (contains(eventTypes, type)) {
- // if this type of event was never bound
- if (!globalEvents[type]) {
- globalEvents[type] = [listener];
- }
- else {
- globalEvents[type].push(listener);
- }
- }
- // If non InteractEvent type, addEventListener to document
- else {
- events.add(document, type, listener, useCapture);
- }
-
- return interact;
- };
-
- /*\
- * interact.off
- [ method ]
- *
- * Removes a global InteractEvent listener or DOM event from `document`
- *
- - type (string | array | object) The types of events that were listened for
- - listener (function) The listener function to be removed
- - useCapture (boolean) #optional useCapture flag for removeEventListener
- = (object) interact
- \*/
- interact.off = function (type, listener, useCapture) {
- if (isString(type) && type.search(' ') !== -1) {
- type = type.trim().split(/ +/);
- }
-
- if (isArray(type)) {
- for (var i = 0; i < type.length; i++) {
- interact.off(type[i], listener, useCapture);
- }
-
- return interact;
- }
-
- if (isObject(type)) {
- for (var prop in type) {
- interact.off(prop, type[prop], listener);
- }
-
- return interact;
- }
-
- if (!contains(eventTypes, type)) {
- events.remove(document, type, listener, useCapture);
- }
- else {
- var index;
-
- if (type in globalEvents
- && (index = indexOf(globalEvents[type], listener)) !== -1) {
- globalEvents[type].splice(index, 1);
- }
- }
-
- return interact;
- };
-
- /*\
- * interact.enableDragging
- [ method ]
- *
- * Deprecated.
- *
- * Returns or sets whether dragging is enabled for any Interactables
- *
- - newValue (boolean) #optional `true` to allow the action; `false` to disable action for all Interactables
- = (boolean | object) The current setting or interact
- \*/
- interact.enableDragging = warnOnce(function (newValue) {
- if (newValue !== null && newValue !== undefined) {
- actionIsEnabled.drag = newValue;
-
- return interact;
- }
- return actionIsEnabled.drag;
- }, 'interact.enableDragging is deprecated and will soon be removed.');
-
- /*\
- * interact.enableResizing
- [ method ]
- *
- * Deprecated.
- *
- * Returns or sets whether resizing is enabled for any Interactables
- *
- - newValue (boolean) #optional `true` to allow the action; `false` to disable action for all Interactables
- = (boolean | object) The current setting or interact
- \*/
- interact.enableResizing = warnOnce(function (newValue) {
- if (newValue !== null && newValue !== undefined) {
- actionIsEnabled.resize = newValue;
-
- return interact;
- }
- return actionIsEnabled.resize;
- }, 'interact.enableResizing is deprecated and will soon be removed.');
-
- /*\
- * interact.enableGesturing
- [ method ]
- *
- * Deprecated.
- *
- * Returns or sets whether gesturing is enabled for any Interactables
- *
- - newValue (boolean) #optional `true` to allow the action; `false` to disable action for all Interactables
- = (boolean | object) The current setting or interact
- \*/
- interact.enableGesturing = warnOnce(function (newValue) {
- if (newValue !== null && newValue !== undefined) {
- actionIsEnabled.gesture = newValue;
-
- return interact;
- }
- return actionIsEnabled.gesture;
- }, 'interact.enableGesturing is deprecated and will soon be removed.');
-
- interact.eventTypes = eventTypes;
-
- /*\
- * interact.debug
- [ method ]
- *
- * Returns debugging data
- = (object) An object with properties that outline the current state and expose internal functions and variables
- \*/
- interact.debug = function () {
- var interaction = interactions[0] || new Interaction();
-
- return {
- interactions : interactions,
- target : interaction.target,
- dragging : interaction.dragging,
- resizing : interaction.resizing,
- gesturing : interaction.gesturing,
- prepared : interaction.prepared,
- matches : interaction.matches,
- matchElements : interaction.matchElements,
-
- prevCoords : interaction.prevCoords,
- startCoords : interaction.startCoords,
-
- pointerIds : interaction.pointerIds,
- pointers : interaction.pointers,
- addPointer : listeners.addPointer,
- removePointer : listeners.removePointer,
- recordPointer : listeners.recordPointer,
-
- snap : interaction.snapStatus,
- restrict : interaction.restrictStatus,
- inertia : interaction.inertiaStatus,
-
- downTime : interaction.downTimes[0],
- downEvent : interaction.downEvent,
- downPointer : interaction.downPointer,
- prevEvent : interaction.prevEvent,
-
- Interactable : Interactable,
- interactables : interactables,
- pointerIsDown : interaction.pointerIsDown,
- defaultOptions : defaultOptions,
- defaultActionChecker : defaultActionChecker,
-
- actionCursors : actionCursors,
- dragMove : listeners.dragMove,
- resizeMove : listeners.resizeMove,
- gestureMove : listeners.gestureMove,
- pointerUp : listeners.pointerUp,
- pointerDown : listeners.pointerDown,
- pointerMove : listeners.pointerMove,
- pointerHover : listeners.pointerHover,
-
- eventTypes : eventTypes,
-
- events : events,
- globalEvents : globalEvents,
- delegatedEvents : delegatedEvents
- };
- };
-
- // expose the functions used to calculate multi-touch properties
- interact.getTouchAverage = touchAverage;
- interact.getTouchBBox = touchBBox;
- interact.getTouchDistance = touchDistance;
- interact.getTouchAngle = touchAngle;
-
- interact.getElementRect = getElementRect;
- interact.matchesSelector = matchesSelector;
- interact.closest = closest;
-
- /*\
- * interact.margin
- [ method ]
- *
- * Returns or sets the margin for autocheck resizing used in
- * @Interactable.getAction. That is the distance from the bottom and right
- * edges of an element clicking in which will start resizing
- *
- - newValue (number) #optional
- = (number | interact) The current margin value or interact
- \*/
- interact.margin = function (newvalue) {
- if (isNumber(newvalue)) {
- margin = newvalue;
-
- return interact;
- }
- return margin;
- };
-
- /*\
- * interact.supportsTouch
- [ method ]
- *
- = (boolean) Whether or not the browser supports touch input
- \*/
- interact.supportsTouch = function () {
- return supportsTouch;
- };
-
- /*\
- * interact.supportsPointerEvent
- [ method ]
- *
- = (boolean) Whether or not the browser supports PointerEvents
- \*/
- interact.supportsPointerEvent = function () {
- return supportsPointerEvent;
- };
-
- /*\
- * interact.stop
- [ method ]
- *
- * Cancels all interactions (end events are not fired)
- *
- - event (Event) An event on which to call preventDefault()
- = (object) interact
- \*/
- interact.stop = function (event) {
- for (var i = interactions.length - 1; i > 0; i--) {
- interactions[i].stop(event);
- }
-
- return interact;
- };
-
- /*\
- * interact.dynamicDrop
- [ method ]
- *
- * Returns or sets whether the dimensions of dropzone elements are
- * calculated on every dragmove or only on dragstart for the default
- * dropChecker
- *
- - newValue (boolean) #optional True to check on each move. False to check only before start
- = (boolean | interact) The current setting or interact
- \*/
- interact.dynamicDrop = function (newValue) {
- if (isBool(newValue)) {
- //if (dragging && dynamicDrop !== newValue && !newValue) {
- //calcRects(dropzones);
- //}
-
- dynamicDrop = newValue;
-
- return interact;
- }
- return dynamicDrop;
- };
-
- /*\
- * interact.pointerMoveTolerance
- [ method ]
- * Returns or sets the distance the pointer must be moved before an action
- * sequence occurs. This also affects tolerance for tap events.
- *
- - newValue (number) #optional The movement from the start position must be greater than this value
- = (number | Interactable) The current setting or interact
- \*/
- interact.pointerMoveTolerance = function (newValue) {
- if (isNumber(newValue)) {
- pointerMoveTolerance = newValue;
-
- return this;
- }
-
- return pointerMoveTolerance;
- };
-
- /*\
- * interact.maxInteractions
- [ method ]
- **
- * Returns or sets the maximum number of concurrent interactions allowed.
- * By default only 1 interaction is allowed at a time (for backwards
- * compatibility). To allow multiple interactions on the same Interactables
- * and elements, you need to enable it in the draggable, resizable and
- * gesturable `'max'` and `'maxPerElement'` options.
- **
- - newValue (number) #optional Any number. newValue <= 0 means no interactions.
- \*/
- interact.maxInteractions = function (newValue) {
- if (isNumber(newValue)) {
- maxInteractions = newValue;
-
- return this;
- }
-
- return maxInteractions;
- };
-
- interact.createSnapGrid = function (grid) {
- return function (x, y) {
- var offsetX = 0,
- offsetY = 0;
-
- if (isObject(grid.offset)) {
- offsetX = grid.offset.x;
- offsetY = grid.offset.y;
- }
-
- var gridx = Math.round((x - offsetX) / grid.x),
- gridy = Math.round((y - offsetY) / grid.y),
-
- newX = gridx * grid.x + offsetX,
- newY = gridy * grid.y + offsetY;
-
- return {
- x: newX,
- y: newY,
- range: grid.range
- };
- };
- };
-
- function endAllInteractions (event) {
- for (var i = 0; i < interactions.length; i++) {
- interactions[i].pointerEnd(event, event);
- }
- }
-
- function listenToDocument (doc) {
- if (contains(documents, doc)) { return; }
-
- var win = doc.defaultView || doc.parentWindow;
-
- // add delegate event listener
- for (var eventType in delegatedEvents) {
- events.add(doc, eventType, delegateListener);
- events.add(doc, eventType, delegateUseCapture, true);
- }
-
- if (PointerEvent) {
- if (PointerEvent === win.MSPointerEvent) {
- pEventTypes = {
- up: 'MSPointerUp', down: 'MSPointerDown', over: 'mouseover',
- out: 'mouseout', move: 'MSPointerMove', cancel: 'MSPointerCancel' };
- }
- else {
- pEventTypes = {
- up: 'pointerup', down: 'pointerdown', over: 'pointerover',
- out: 'pointerout', move: 'pointermove', cancel: 'pointercancel' };
- }
-
- events.add(doc, pEventTypes.down , listeners.selectorDown );
- events.add(doc, pEventTypes.move , listeners.pointerMove );
- events.add(doc, pEventTypes.over , listeners.pointerOver );
- events.add(doc, pEventTypes.out , listeners.pointerOut );
- events.add(doc, pEventTypes.up , listeners.pointerUp );
- events.add(doc, pEventTypes.cancel, listeners.pointerCancel);
-
- // autoscroll
- events.add(doc, pEventTypes.move, listeners.autoScrollMove);
- }
- else {
- events.add(doc, 'mousedown', listeners.selectorDown);
- events.add(doc, 'mousemove', listeners.pointerMove );
- events.add(doc, 'mouseup' , listeners.pointerUp );
- events.add(doc, 'mouseover', listeners.pointerOver );
- events.add(doc, 'mouseout' , listeners.pointerOut );
-
- events.add(doc, 'touchstart' , listeners.selectorDown );
- events.add(doc, 'touchmove' , listeners.pointerMove );
- events.add(doc, 'touchend' , listeners.pointerUp );
- events.add(doc, 'touchcancel', listeners.pointerCancel);
-
- // autoscroll
- events.add(doc, 'mousemove', listeners.autoScrollMove);
- events.add(doc, 'touchmove', listeners.autoScrollMove);
- }
-
- events.add(win, 'blur', endAllInteractions);
-
- try {
- if (win.frameElement) {
- var parentDoc = win.frameElement.ownerDocument,
- parentWindow = parentDoc.defaultView;
-
- events.add(parentDoc , 'mouseup' , listeners.pointerEnd);
- events.add(parentDoc , 'touchend' , listeners.pointerEnd);
- events.add(parentDoc , 'touchcancel' , listeners.pointerEnd);
- events.add(parentDoc , 'pointerup' , listeners.pointerEnd);
- events.add(parentDoc , 'MSPointerUp' , listeners.pointerEnd);
- events.add(parentWindow, 'blur' , endAllInteractions );
- }
- }
- catch (error) {
- interact.windowParentError = error;
- }
-
- if (events.useAttachEvent) {
- // For IE's lack of Event#preventDefault
- events.add(doc, 'selectstart', function (event) {
- var interaction = interactions[0];
-
- if (interaction.currentAction()) {
- interaction.checkAndPreventDefault(event);
- }
- });
-
- // For IE's bad dblclick event sequence
- events.add(doc, 'dblclick', doOnInteractions('ie8Dblclick'));
- }
-
- documents.push(doc);
- }
-
- listenToDocument(document);
-
- function indexOf (array, target) {
- for (var i = 0, len = array.length; i < len; i++) {
- if (array[i] === target) {
- return i;
- }
- }
-
- return -1;
- }
-
- function contains (array, target) {
- return indexOf(array, target) !== -1;
- }
-
- function matchesSelector (element, selector, nodeList) {
- if (ie8MatchesSelector) {
- return ie8MatchesSelector(element, selector, nodeList);
- }
-
- // remove /deep/ from selectors if shadowDOM polyfill is used
- if (window !== realWindow) {
- selector = selector.replace(/\/deep\//g, ' ');
- }
-
- return element[prefixedMatchesSelector](selector);
- }
-
- function matchesUpTo (element, selector, limit) {
- while (isElement(element)) {
- if (matchesSelector(element, selector)) {
- return true;
- }
-
- element = parentElement(element);
-
- if (element === limit) {
- return matchesSelector(element, selector);
- }
- }
-
- return false;
- }
-
- // For IE8's lack of an Element#matchesSelector
- // taken from http://tanalin.com/en/blog/2012/12/matches-selector-ie8/ and modified
- if (!(prefixedMatchesSelector in Element.prototype) || !isFunction(Element.prototype[prefixedMatchesSelector])) {
- ie8MatchesSelector = function (element, selector, elems) {
- elems = elems || element.parentNode.querySelectorAll(selector);
-
- for (var i = 0, len = elems.length; i < len; i++) {
- if (elems[i] === element) {
- return true;
- }
- }
-
- return false;
- };
- }
-
- // requestAnimationFrame polyfill
- (function() {
- var lastTime = 0,
- vendors = ['ms', 'moz', 'webkit', 'o'];
-
- for(var x = 0; x < vendors.length && !realWindow.requestAnimationFrame; ++x) {
- reqFrame = realWindow[vendors[x]+'RequestAnimationFrame'];
- cancelFrame = realWindow[vendors[x]+'CancelAnimationFrame'] || realWindow[vendors[x]+'CancelRequestAnimationFrame'];
- }
-
- if (!reqFrame) {
- reqFrame = function(callback) {
- var currTime = new Date().getTime(),
- timeToCall = Math.max(0, 16 - (currTime - lastTime)),
- id = setTimeout(function() { callback(currTime + timeToCall); },
- timeToCall);
- lastTime = currTime + timeToCall;
- return id;
- };
- }
-
- if (!cancelFrame) {
- cancelFrame = function(id) {
- clearTimeout(id);
- };
- }
- }());
-
- /* global exports: true, module, define */
-
- // http://documentcloud.github.io/underscore/docs/underscore.html#section-11
- if (typeof exports !== 'undefined') {
- if (typeof module !== 'undefined' && module.exports) {
- exports = module.exports = interact;
- }
- exports.interact = interact;
- }
- // AMD
- else if (typeof define === 'function' && define.amd) {
- define('interact', function() {
- return interact;
- });
- }
- else {
- realWindow.interact = interact;
- }
-
-} (typeof window === 'undefined'? undefined : window));
diff --git a/nengo_gui/static/lib/js/jquery-2.1.3.min.js b/nengo_gui/static/lib/js/jquery-2.1.3.min.js
deleted file mode 100644
index 25714ed2..00000000
--- a/nengo_gui/static/lib/js/jquery-2.1.3.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
-!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)
-},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),f.removeChild(c),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
-},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec=/#.*$/,fc=/([?&])_=[^&]*/,gc=/^(.*?):[ \t]*([^\r\n]*)$/gm,hc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,ic=/^(?:GET|HEAD)$/,jc=/^\/\//,kc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,lc={},mc={},nc="*/".concat("*"),oc=a.location.href,pc=kc.exec(oc.toLowerCase())||[];function qc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function rc(a,b,c,d){var e={},f=a===mc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function sc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function tc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function uc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:oc,type:"GET",isLocal:hc.test(pc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":nc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?sc(sc(a,n.ajaxSettings),b):sc(n.ajaxSettings,a)},ajaxPrefilter:qc(lc),ajaxTransport:qc(mc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=gc.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||oc)+"").replace(ec,"").replace(jc,pc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=kc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===pc[1]&&h[2]===pc[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(pc[3]||("http:"===pc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),rc(lc,k,b,v),2===t)return v;i=n.event&&k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!ic.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=fc.test(d)?d.replace(fc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+nc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=rc(mc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=tc(k,v,f)),u=uc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var vc=/%20/g,wc=/\[\]$/,xc=/\r?\n/g,yc=/^(?:submit|button|image|reset|file)$/i,zc=/^(?:input|select|textarea|keygen)/i;function Ac(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||wc.test(a)?d(a,e):Ac(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Ac(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Ac(c,a[c],b,e);return d.join("&").replace(vc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&zc.test(this.nodeName)&&!yc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(xc,"\r\n")}}):{name:b.name,value:c.replace(xc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Bc=0,Cc={},Dc={0:200,1223:204},Ec=n.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Cc)Cc[a]()}),k.cors=!!Ec&&"withCredentials"in Ec,k.ajax=Ec=!!Ec,n.ajaxTransport(function(a){var b;return k.cors||Ec&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Bc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Cc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Dc[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Cc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+