jquery.jsPlumb-1.2-all-min.js 19 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function(){var e=/MSIE/.test(navigator.userAgent)&&!window.opera,g=null,d=function(){j.repaintEverything()},f=true,k={},l=[],i={},o={},t=true,r=[],y=1200,E=function(a,b,c){var h=function(p,s){if(p===s)return true;else if(typeof p=="object"&&typeof s=="object"){var u=true;for(var v in p)if(!h(p[v],s[v])){u=false;break}for(v in s)if(!h(s[v],p[v])){u=false;break}return u}};c=+c||0;for(var m=a.length;c<m;c++)if(h(a[c],b))return c;return-1},H=function(a,b,c){var h=a[b];if(h==null){h=[];a[b]=h}h.push(c)},
  2. F=function(a,b){var c=B(a,"id"),h=k[c];if(h){L(c,b);for(var m=l[c],p=r[c],s=0;s<h.length;s++){var u=h[s],v=h[s].anchor.compute([m.left,m.top],p);u.paint(v);u=u.connections;for(v=0;v<u.length;v++)u[v].paint(c,b)}}},G=function(a,b){var c=null;if(typeof a=="object"&&a.length){c=[];for(var h=0;h<a.length;h++){var m=x(a[h]),p=B(m,"id");c.push(b(m,p))}}else{m=x(a);p=B(m,"id");c=b(m,p)}return c},B=function(a,b){var c=j.CurrentLibrary.getElementObject(a);return j.CurrentLibrary.getAttribute(c,b)},R=function(a,
  3. b,c){a=j.CurrentLibrary.getElementObject(a);j.CurrentLibrary.setAttribute(a,b,c)},x=function(a){return j.CurrentLibrary.getElementObject(a)},V=function(a){a=j.CurrentLibrary.getElementObject(a);return j.CurrentLibrary.getSize(a)},T=function(a,b,c,h){if((c==null?t:c)&&j.CurrentLibrary.isDragSupported(a)){var m=h||j.Defaults.DragOptions;m=j.extend({},m);var p=j.CurrentLibrary.dragEvents.drag;(function(s,u,v){m[p]=I(m[p],v);u=o[u];m.disabled=u==null?false:!u;j.CurrentLibrary.initDraggable(s,m)})(a,b,
  4. function(){var s=j.CurrentLibrary.getUIPosition(arguments);F(a,s);s=j.CurrentLibrary.getElementObject(a);j.CurrentLibrary.addClass(s,"jsPlumb_dragged")})}},W=function(a){var b=document.createElement("canvas");document.body.appendChild(b);b.style.position="absolute";if(a)b.className=a;a=b;var c=B(a,"id");if(!c){c="_jsPlumb_"+new String((new Date).getTime());R(a,"id",c)}if(e){j.sizeCanvas(b,0,0,y,y);b=G_vmlCanvasManager.initElement(b)}return b},U=function(a,b){var c=k[a];if(c&&c.length)for(var h=0;h<
  5. c.length;h++)for(var m=0;m<c[h].connections.length;m++)if(b(c[h].connections[m]))return},M=function(a){if(a!=null)try{document.body.removeChild(a)}catch(b){}},X=function(a,b,c){a=a[b];if(a!=null){c=E(a,c);if(c>=0){delete a[c];a.splice(c,1);return true}}return false},Y=function(a,b){var c=B(a,"id");U(c,function(h){h.canvas.style.display=b})},Z=function(a){U(a,function(b){b.canvas.style.display="none"==b.canvas.style.display?"block":"none"})},L=function(a,b,c){if(c||b==null){x(a);r[a]=V(a);b=j.CurrentLibrary.getElementObject(a);
  6. b=j.CurrentLibrary.getOffset(b);l[a]=b}else l[a]=b},I=function(a,b){a=a||function(){};b=b||function(){};return function(){try{b.apply(this,arguments)}catch(c){}try{a.apply(this,arguments)}catch(h){}}},ba=function(a){var b=this;this.x=a.x||0;this.y=a.y||0;var c=a.orientation||[0,0];this.offsets=a.offsets||[0,0];this.compute=function(h,m){return[h[0]+b.x*m[0]+b.offsets[0],h[1]+b.y*m[1]+b.offsets[1]]};this.getOrientation=function(){return c}},ca=function(a){var b=a.reference,c=V(a.referenceCanvas),h=
  7. 0,m=0,p=null;this.compute=function(s){m=h=0;return[s[0]+c[0]/2,s[1]+c[1]/2]};this.getOrientation=function(){if(p)return p;else{var s=b.getOrientation();return[Math.abs(s[0])*h*-1,Math.abs(s[1])*m*-1]}};this.over=function(s){p=s.getOrientation()};this.out=function(){p=null}},aa=function(a){var b=this;this.source=x(a.source);this.target=x(a.target);this.sourceId=B(this.source,"id");this.targetId=B(this.target,"id");this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.endpoints=[];this.endpointStyles=
  8. [];var c=function(p,s,u){if(p)b.endpoints[s]=p;else{if(!u.endpoints)u.endpoints=[null,null];p=u.endpoints[s]||u.endpoint||j.Defaults.Endpoints[s]||j.Defaults.Endpoint||new j.Endpoints.Dot;if(!u.endpointStyles)u.endpointStyles=[null,null];b.endpoints[s]=new S({style:u.endpointStyles[s]||u.endpointStyle||j.Defaults.EndpointStyles[s]||j.Defaults.EndpointStyle,endpoint:p,connections:[b],anchor:u.anchors?u.anchors[s]:j.Defaults.Anchors[s]||j.Anchors.BottomCenter,source:b.source})}};c(a.sourceEndpoint,
  9. 0,a);c(a.targetEndpoint,1,a);this.connector=this.endpoints[0].connector||this.endpoints[1].connector||a.connector||j.Defaults.Connector||new j.Connectors.Bezier;this.paintStyle=this.endpoints[0].connectorStyle||this.endpoints[1].connectorStyle||a.paintStyle||j.Defaults.PaintStyle;L(this.sourceId);L(this.targetId);c=l[this.sourceId];var h=r[this.sourceId];c=this.endpoints[0].anchor.compute([c.left,c.top],h);this.endpoints[0].paint(c);c=l[this.targetId];h=r[this.targetId];c=this.endpoints[1].anchor.compute([c.left,
  10. c.top],h);this.endpoints[1].paint(c);var m=W(j.connectorClass);this.canvas=m;this.paint=function(p,s,u){g&&g.debug("Painting Connection; element in motion is "+p+"; ui is ["+s+"]; recalc is ["+u+"]");var v=p!=this.sourceId,D=v?this.sourceId:this.targetId,w=v?0:1,q=v?1:0;if(this.canvas.getContext){L(p,s,u);u&&L(D);s=l[p];u=l[D];p=r[p];var O=r[D];D=m.getContext("2d");var J=this.endpoints[q].anchor.compute([s.left,s.top],p,[u.left,u.top],O);this.endpoints[q].anchor.getOrientation();s=this.endpoints[w].anchor.compute([u.left,
  11. u.top],O,[s.left,s.top],p);this.endpoints[w].anchor.getOrientation();w=this.connector.compute(J,s,this.endpoints[q].anchor,this.endpoints[w].anchor,this.paintStyle.lineWidth);j.sizeCanvas(m,w[0],w[1],w[2],w[3]);j.extend(D,this.paintStyle);if(this.paintStyle.gradient&&!e){v=v?D.createLinearGradient(w[4],w[5],w[6],w[7]):D.createLinearGradient(w[6],w[7],w[4],w[5]);for(q=0;q<this.paintStyle.gradient.stops.length;q++)v.addColorStop(this.paintStyle.gradient.stops[q][0],this.paintStyle.gradient.stops[q][1]);
  12. D.strokeStyle=v}this.connector.paint(w,D)}};this.repaint=function(){this.paint(this.sourceId,null,true)};T(b.source,b.sourceId,a.draggable,a.dragOptions);T(b.target,b.targetId,a.draggable,a.dragOptions);this.source.resize&&this.source.resize(function(){j.repaint(b.sourceId)})},S=function(a){a=a||{};j.extend({},a);var b=this;b.anchor=a.anchor||j.Anchors.TopCenter;var c=a.endpoint||new j.Endpoints.Dot,h=a.style||j.Defaults.EndpointStyle;this.connectorStyle=a.connectorStyle;this.connector=a.connector;
  13. var m=a.source,p=B(m,"id"),s=a.maxConnections||1;this.canvas=a.canvas||W(j.endpointClass);this.connections=a.connections||[];var u=a.reattach||false,v=null,D=null;this.addConnection=function(n){b.connections.push(n)};this.removeConnection=function(n){n=E(b.connections,n);n>=0&&b.connections.splice(n,1)};this.makeInPlaceCopy=function(){return new S({anchor:b.anchor,source:m,style:h,endpoint:c})};this.isConnectedTo=function(n){var C=false;if(n)for(var z=0;z<b.connections.length;z++)if(b.connections[z].endpoints[1]==
  14. n){C=true;break}return C};this.isFloating=function(){return v!=null};this.isFull=function(){return s<1?false:b.connections.length>=s};this.paint=function(n,C,z){g&&g.debug("Painting Endpoint with elementId ["+p+"]; anchorPoint is ["+n+"]");if(n==null){n=l[p];var N=r[p];if(n==null||N==null){L(p);n=l[p];N=r[p]}n=b.anchor.compute([n.left,n.top],N)}c.paint(n,b.anchor.getOrientation(),z||b.canvas,h,C||h)};if(a.isSource&&j.CurrentLibrary.isDragSupported(m)){var w=null,q=null,O=false,J=null,A=a.dragOptions||
  15. {},K=j.extend({},j.CurrentLibrary.defaultDragOptions);A=j.extend(K,A);K=j.CurrentLibrary.dragEvents.start;var P=j.CurrentLibrary.dragEvents.stop,Q=j.CurrentLibrary.dragEvents.drag;A[K]=I(A[K],function(){D=b.makeInPlaceCopy();D.paint();w=document.createElement("div");document.body.appendChild(w);var n=""+new String((new Date).getTime());R(x(w),"id",n);L(n);R(x(b.canvas),"dragId",n);R(x(b.canvas),"elId",p);var C=new ca({reference:b.anchor,referenceCanvas:b.canvas});v=new S({style:{fillStyle:"rgba(0,0,0,0)"},
  16. endpoint:c,anchor:C,source:w});q=b.connections.length==0||b.connections.length<s?null:b.connections[0];if(q==null){q=new aa({sourceEndpoint:b,targetEndpoint:v,source:x(m),target:x(w),anchors:[b.anchor,C],paintStyle:a.connectorStyle,connector:a.connector});b.addConnection(q)}else{O=true;C=q.sourceId==p?0:1;q.floatingAnchorIndex=C;b.removeConnection(q);if(C==0){J=[q.source,q.sourceId];q.source=x(w);q.sourceId=n}else{J=[q.target,q.targetId];q.target=x(w);q.targetId=n}q.suspendedEndpoint=q.endpoints[C];
  17. q.endpoints[C]=v}i[n]=q;v.addConnection(q);H(k,n,v)});A[Q]=I(A[Q],function(){var n=j.CurrentLibrary.getUIPosition(arguments);F(x(w),n)});A[P]=I(A[P],function(){X(k,null,v);var n=[v.canvas,w,D.canvas];for(var C in n)M(n[C]);n=q.floatingAnchorIndex==null?1:q.floatingAnchorIndex;if(q.endpoints[n]==v)if(O&&q.suspendedEndpoint)if(u){q.floatingAnchorIndex=null;if(n==0){q.source=J[0];q.sourceId=J[1]}else{q.target=J[0];q.targetId=J[1]}q.endpoints[n]=q.suspendedEndpoint;q.suspendedEndpoint.addConnection(q);
  18. j.repaint(J[1])}else{q.endpoints[0].removeConnection(q);q.endpoints[1].removeConnection(q);M(q.canvas)}else{M(q.canvas);b.removeConnection(q)}q=null;delete v;delete D;b.paint()});K=x(b.canvas);j.CurrentLibrary.initDraggable(K,A)}if(a.isTarget&&j.CurrentLibrary.isDropSupported(m)){A=a.dropOptions||j.Defaults.DropOptions;A=j.extend({},A);K=j.CurrentLibrary.dragEvents.drop;P=j.CurrentLibrary.dragEvents.over;Q=j.CurrentLibrary.dragEvents.out;A[K]=I(A[K],function(){var n=j.CurrentLibrary.getDragObject(arguments),
  19. C=B(x(n),"dragId");n=B(x(n),"elId");var z=i[C],N=z.floatingAnchorIndex==null?1:z.floatingAnchorIndex;if(N==0){z.source=m;z.sourceId=p}else{z.target=m;z.targetId=p}z.endpoints[N].removeConnection(z);z.suspendedEndpoint&&z.suspendedEndpoint.removeConnection(z);z.endpoints[N]=b;b.addConnection(z);T(m,p,a.draggable,{});j.repaint(n);delete i[C]});A[P]=I(A[P],function(){var n=j.CurrentLibrary.getDragObject(arguments);n=B(x(n),"dragId");n=i[n];n.endpoints[n.floatingAnchorIndex==null?1:n.floatingAnchorIndex].anchor.over(b.anchor)});
  20. A[Q]=I(A[Q],function(){var n=j.CurrentLibrary.getDragObject(arguments);n=B(x(n),"dragId");n=i[n];n.endpoints[n.floatingAnchorIndex==null?1:n.floatingAnchorIndex].anchor.out()});j.CurrentLibrary.initDroppable(x(b.canvas),A)}return b},j=window.jsPlumb={Defaults:{Anchors:[null,null],Connector:null,DragOptions:{},DropOptions:{},Endpoint:null,Endpoints:[null,null],EndpointStyle:{fillStyle:null},EndpointStyles:[null,null],MaxConnections:null,PaintStyle:{lineWidth:10,strokeStyle:"red"},Scope:"_jsPlumb_DefaultScope"},
  21. connectorClass:"_jsPlumb_connector",endpointClass:"_jsPlumb_endpoint",Anchors:{},Connectors:{},Endpoints:{},addEndpoint:function(a,b){b=j.extend({},b);var c=x(a),h=B(a,"id");b.source=c;L(h);c=new S(b);H(k,h,c);var m=l[h];h=c.anchor.compute([m.left,m.top],r[h]);c.paint(h);return c},addEndpoints:function(a,b){for(var c=[],h=0;h<b.length;h++)c.push(j.addEndpoint(a,b[h]));return c},animate:function(a,b,c){var h=x(a),m=B(a,"id");c=c||{};a=j.CurrentLibrary.dragEvents.step;c[a]=I(c[a],function(){j.repaint(m)});
  22. j.CurrentLibrary.animate(h,b,c)},connect:function(a){if(!(a.sourceEndpoint&&a.sourceEndpoint.isFull()))if(!(a.targetEndpoint&&a.targetEndpoint.isFull())){var b=new aa(a);a.sourceEndpoint||H(k,b.sourceId,b.endpoints[0]);a.targetEndpoint||H(k,b.targetId,b.endpoints[1]);b.endpoints[0].addConnection(b);b.endpoints[1].addConnection(b);F(b.source);return b}},detach:function(a,b){U(a,function(c){if(c.sourceId==a&&c.targetId==b||c.targetId==a&&c.sourceId==b){M(c.canvas);c.endpoints[0].removeConnection(c);
  23. c.endpoints[1].removeConnection(c);return true}})},detachAll:function(a){a=B(a,"id");if((a=k[a])&&a.length)for(var b=0;b<a.length;b++){var c=a[b].connections.length;if(c>0)for(var h=0;h<c;h++){var m=a[b].connections[0];M(m.canvas);m.endpoints[0].removeConnection(m);m.endpoints[1].removeConnection(m)}}},detachEverything:function(){for(var a in k){var b=k[a];if(b&&b.length)for(var c=0;c<b.length;c++){var h=b[c].connections.length;if(h>0)for(var m=0;m<h;m++){var p=b[c].connections[0];M(p.canvas);p.endpoints[0].removeConnection(p);
  24. p.endpoints[1].removeConnection(p)}}}},extend:function(a,b){return j.CurrentLibrary.extend(a,b)},hide:function(a){Y(a,"none")},makeAnchor:function(a,b){var c={};if(arguments.length==1)j.extend(c,a);else{c={x:a,y:b};if(arguments.length>=4)c.orientation=[arguments[2],arguments[3]];if(arguments.length==6)c.offsets=[arguments[4],arguments[5]]}return new ba(c)},repaint:function(a){var b=function(h){h=x(h);F(h)};if(typeof a=="object")for(var c=0;c<a.length;c++)b(a[c]);else b(a)},repaintEverything:function(){for(var a in k)F(x(a))},
  25. removeAllEndpoints:function(a){a=B(a,"id");j.detachAll(a);var b=k[a];for(var c in b)M(b[c].canvas);k[a]=[]},removeEndpoint:function(a,b){var c=B(a,"id");k[c]&&X(k,c,b)&&M(b.canvas)},setAutomaticRepaint:function(a){f=a},setDefaultNewCanvasSize:function(a){y=a},setDraggable:function(a,b){return G(a,function(c,h){o[h]=b;j.CurrentLibrary.isDragSupported(c)&&j.CurrentLibrary.setDraggable(c,b)})},setDraggableByDefault:function(a){t=a},setDebugLog:function(a){g=a},setRepaintFunction:function(a){d=a},show:function(a){Y(a,
  26. "block")},sizeCanvas:function(a,b,c,h,m){if(a){a.style.height=m+"px";a.height=m;a.style.width=h+"px";a.width=h;a.style.left=b+"px";a.style.top=c+"px"}},getTestHarness:function(){return{endpointCount:function(a){return(a=k[a])?a.length:0},findIndex:E}},toggle:Z,toggleVisible:Z,toggleDraggable:function(a){return G(a,function(b,c){var h=o[c]==null?t:o[c];h=!h;o[c]=h;j.CurrentLibrary.setDraggable(b,h);return h})},unload:function(){delete k;delete l;delete r;delete i;delete o},wrap:I}})();
  27. (function(e){e.fn.plumb=function(g){g=e.extend({},g);return this.each(function(){var d=e.extend({source:e(this)},g);jsPlumb.connect(d)})};e.fn.detach=function(g){return this.each(function(){var d=e(this).attr("id");if(typeof g=="string")g=[g];for(var f=0;f<g.length;f++)jsPlumb.detach(d,g[f])})};e.fn.detachAll=function(){return this.each(function(){var g=e(this).attr("id");jsPlumb.detachAll(g)})};e.fn.addEndpoint=function(g){var d=[];this.each(function(){d.push(jsPlumb.addEndpoint(e(this).attr("id"),
  28. g))});return d[0]};e.fn.addEndpoints=function(g){var d=[];return this.each(function(){for(var f=jsPlumb.addEndpoints(e(this).attr("id"),g),k=0;k<f.length;k++)d.push(f[k])})};e.fn.removeEndpoint=function(g){this.each(function(){jsPlumb.removeEndpoint(e(this).attr("id"),g)})}})(jQuery);
  29. (function(){jsPlumb.CurrentLibrary={dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop"},extend:function(e,g){return $.extend(e,g)},getElementObject:function(e){return typeof e=="string"?$("#"+e):$(e)},getOffset:function(e){return e.offset()},getSize:function(e){return[e.outerWidth(),e.outerHeight()]},getAttribute:function(e,g){return e.attr(g)},setAttribute:function(e,g,d){e.attr(g,d)},addClass:function(e,g){e.addClass(g)},initDraggable:function(e,g){g.helper=
  30. null;g.scope=g.scope||jsPlumb.Defaults.Scope;e.draggable(g)},isDragSupported:function(e){return e.draggable},setDraggable:function(e,g){e.draggable("option","disabled",!g)},initDroppable:function(e,g){g.scope=g.scope||jsPlumb.Defaults.Scope;e.droppable(g)},isDropSupported:function(e){return e.droppable},animate:function(e,g,d){e.animate(g,d)},getUIPosition:function(e){e=e[1];return e.absolutePosition||e.offset},getDragObject:function(e){return e[1].draggable}}})();
  31. (function(){jsPlumb.Anchors.TopCenter=jsPlumb.makeAnchor(0.5,0,0,-1);jsPlumb.Anchors.BottomCenter=jsPlumb.makeAnchor(0.5,1,0,1);jsPlumb.Anchors.LeftMiddle=jsPlumb.makeAnchor(0,0.5,-1,0);jsPlumb.Anchors.RightMiddle=jsPlumb.makeAnchor(1,0.5,1,0);jsPlumb.Anchors.Center=jsPlumb.makeAnchor(0.5,0.5,0,0);jsPlumb.Anchors.TopRight=jsPlumb.makeAnchor(1,0,0,-1);jsPlumb.Anchors.BottomRight=jsPlumb.makeAnchor(1,1,0,1);jsPlumb.Anchors.TopLeft=jsPlumb.makeAnchor(0,0,0,-1);jsPlumb.Anchors.BottomLeft=jsPlumb.makeAnchor(0,
  32. 1,0,1);jsPlumb.Connectors.Straight=function(){this.compute=function(e,g,d,f,k){d=Math.abs(e[0]-g[0]);f=Math.abs(e[1]-g[1]);var l=0.45*d,i=0.45*f;d*=1.9;f*=1.9;var o=Math.min(e[0],g[0])-l,t=Math.min(e[1],g[1])-i;if(d<2*k){d=2*k;o=e[0]+(g[0]-e[0])/2-k;l=(d-Math.abs(e[0]-g[0]))/2}if(f<2*k){f=2*k;t=e[1]+(g[1]-e[1])/2-k;i=(f-Math.abs(e[1]-g[1]))/2}return[o,t,d,f,e[0]<g[0]?d-l:l,e[1]<g[1]?f-i:i,e[0]<g[0]?l:d-l,e[1]<g[1]?i:f-i]};this.paint=function(e,g){g.beginPath();g.moveTo(e[4],e[5]);g.lineTo(e[6],e[7]);
  33. g.stroke()}};jsPlumb.Connectors.Bezier=function(e){var g=this;this.majorAnchor=e||150;this.minorAnchor=10;this._findControlPoint=function(d,f,k,l,i){l=l.getOrientation();i=i.getOrientation();var o=[],t=g.majorAnchor,r=g.minorAnchor;if(l[0]!=i[0]||l[1]==i[1]){i[0]==0?o.push(k[0]<f[0]?d[0]+r:d[0]-r):o.push(d[0]+t*i[0]);i[1]==0?o.push(k[1]<f[1]?d[1]+r:d[1]-r):o.push(d[1]+t*l[1])}else{l[0]==0?o.push(f[0]<k[0]?d[0]+r:d[0]-r):o.push(d[0]-t*l[0]);l[1]==0?o.push(f[1]<k[1]?d[1]+r:d[1]-r):o.push(d[1]+t*i[1])}return o};
  34. this.compute=function(d,f,k,l,i){i=i||0;var o=Math.abs(d[0]-f[0])+i,t=Math.abs(d[1]-f[1])+i,r=Math.min(d[0],f[0])-i/2,y=Math.min(d[1],f[1])-i/2,E=d[0]<f[0]?o-i/2:i/2,H=d[1]<f[1]?t-i/2:i/2,F=d[0]<f[0]?i/2:o-i/2;i=d[1]<f[1]?i/2:t-i/2;var G=g._findControlPoint([E,H],d,f,k,l);d=g._findControlPoint([F,i],f,d,l,k);f=Math.min(Math.min(E,F),Math.min(G[0],d[0]));k=Math.max(Math.max(E,F),Math.max(G[0],d[0]));if(k>o)o=k;if(f<0){r+=f;f=Math.abs(f);o+=f;G[0]+=f;E+=f;F+=f;d[0]+=f}f=Math.min(Math.min(H,i),Math.min(G[1],
  35. d[1]));k=Math.max(Math.max(H,i),Math.max(G[1],d[1]));if(k>t)t=k;if(f<0){y+=f;f=Math.abs(f);t+=f;G[1]+=f;H+=f;i+=f;d[1]+=f}return[r,y,o,t,E,H,F,i,G[0],G[1],d[0],d[1]]};this.paint=function(d,f){f.beginPath();f.moveTo(d[4],d[5]);f.bezierCurveTo(d[8],d[9],d[10],d[11],d[6],d[7]);f.stroke()}};jsPlumb.Endpoints.Dot=function(e){e=e||{radius:10};var g=this;this.radius=e.radius;var d=0.5*this.radius,f=this.radius/3,k=function(l){try{return parseInt(l)}catch(i){if(l.substring(l.length-1)=="%")return parseInt(l.substring(0,
  36. l-1))}};this.paint=function(l,i,o,t,r){var y=t.radius||g.radius;jsPlumb.sizeCanvas(o,l[0]-y,l[1]-y,y*2,y*2);l=o.getContext("2d");o=jsPlumb.extend({},t);if(o.fillStyle==null)o.fillStyle=r.strokeStyle;jsPlumb.extend(l,o);r=/MSIE/.test(navigator.userAgent)&&!window.opera;if(t.gradient&&!r){r=t.gradient;o=d;var E=f;if(r.offset)o=k(r.offset);if(r.innerRadius)E=k(r.innerRadius);r=[o,E];i=l.createRadialGradient(y,y,y,y+(i[0]==1?r[0]*-1:r[0]),y+(i[1]==1?r[0]*-1:r[0]),r[1]);for(r=0;r<t.gradient.stops.length;r++)i.addColorStop(t.gradient.stops[r][0],
  37. t.gradient.stops[r][1]);l.fillStyle=i}l.beginPath();l.arc(y,y,y,0,Math.PI*2,true);l.closePath();l.fill()}};jsPlumb.Endpoints.Rectangle=function(e){e=e||{width:20,height:20};var g=this;this.width=e.width;this.height=e.height;this.paint=function(d,f,k,l,i){var o=l.width||g.width,t=l.height||g.height;jsPlumb.sizeCanvas(k,d[0]-o/2,d[1]-t/2,o,t);d=k.getContext("2d");k=jsPlumb.extend({},l);if(k.fillStyle==null)k.fillStyle=i.strokeStyle;jsPlumb.extend(d,k);i=/MSIE/.test(navigator.userAgent)&&!window.opera;
  38. if(l.gradient&&!i){f=d.createLinearGradient(f[0]==1?o:f[0]==0?o/2:0,f[1]==1?t:f[1]==0?t/2:0,f[0]==-1?o:f[0]==0?t/2:0,f[1]==-1?t:f[1]==0?t/2:0);for(i=0;i<l.gradient.stops.length;i++)f.addColorStop(l.gradient.stops[i][0],l.gradient.stops[i][1]);d.fillStyle=f}d.beginPath();d.rect(0,0,o,t);d.closePath();d.fill()}};jsPlumb.Endpoints.Triangle=function(e){e=e||{width:15,height:15};var g=this;this.width=e.width;this.height=e.height;this.paint=function(d,f,k,l){var i=l.width||g.width,o=l.height||g.height;
  39. jsPlumb.sizeCanvas(k,d[0]-i/2,d[1]-o/2,i,o);d=k.getContext("2d");var t=k=0,r=0;if(f[0]==1){k=i;t=o;r=180}if(f[1]==-1){k=i;r=90}if(f[1]==1){t=o;r=-90}d.fillStyle=l.fillStyle;d.translate(k,t);d.rotate(r*Math.PI/180);d.beginPath();d.moveTo(0,0);d.lineTo(i/2,o/2);d.lineTo(0,o);d.closePath();d.fill()}};jsPlumb.Endpoints.Image=function(e){var g=this;this.img=new Image;this.img.onload=function(){g.ready=true};this.img.src=e.url;var d=function(f,k,l,i){k=g.img.width||i.width;i=g.img.height||i.height;jsPlumb.sizeCanvas(l,
  40. f[0]-k/2,f[1]-i/2,k,i);l.getContext("2d").drawImage(g.img,0,0)};this.paint=function(f,k,l,i,o){g.ready?d(f,k,l,i,o):window.setTimeout(function(){g.paint(f,k,l,i,o)},200)}}})();