jquery.jsPlumb-1.2.1-all-min.js 23 KB

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