if(!Array.prototype.indexOf)Array.prototype.indexOf=function(j,h,d){h=+h||0;for(var e=this.length;h=0){delete a[c];a.splice(c,1);return true}}return false},X=function(a,b){N(a,function(c){c.canvas.style.display=b})},Y=function(a){N(a,function(b){b.canvas.style.display="none"==b.canvas.style.display?"block":"none"})},I=function(a,b,c){d&&d.debug("updating offset for element ["+a+"]; ui is ["+ b+"]; recalc is ["+c+"]");if(c||b==null){b=$("#"+a);z[a]=[b.outerWidth(),b.outerHeight()];k[a]=b.offset()}else{c=b.absolutePosition||b.offset;b=b!=null?c:$("#"+a).offset();k[a]=b}},K=function(a,b){a=a||function(){};return function(c,g){b(c,g);a(c,g)}},aa=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(g,n){return[g[0]+b.x*n[0]+b.offsets[0],g[1]+b.y*n[1]+b.offsets[1]]};this.getOrientation=function(){return c}},ba=function(a){var b= a.reference,c=0,g=0,n=null;this.compute=function(o){g=c=0;return[o[0],o[1]]};this.getOrientation=function(){if(n)return n;else{var o=b.getOrientation();return[Math.abs(o[0])*c*-1,Math.abs(o[1])*g*-1]}};this.over=function(o){n=o.getOrientation()};this.out=function(){n=null}},R=function(a){var b=this;this.source=typeof a.source=="string"?$("#"+a.source):a.source;this.target=typeof a.target=="string"?$("#"+a.target):a.target;this.sourceId=$(this.source).attr("id");this.targetId=$(this.target).attr("id"); this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.endpoints=[];this.endpointStyles=[];var c=function(o,t,r){if(o)b.endpoints[t]=o;else{if(!r.endpoints)r.endpoints=[null,null];o=r.endpoints[t]||r.endpoint||w.Defaults.Endpoints[t]||w.Defaults.Endpoint||new w.Endpoints.Dot;if(!r.endpointStyles)r.endpointStyles=[null,null];b.endpoints[t]=new Q({style:r.endpointStyles[t]||r.endpointStyle||w.Defaults.EndpointStyles[t]||w.Defaults.EndpointStyle,endpoint:o,connections:[b],anchor:r.anchors? r.anchors[t]:w.Defaults.Anchors[t]||w.Anchors.BottomCenter})}};c(a.sourceEndpoint,0,a);c(a.targetEndpoint,1,a);this.connector=this.endpoints[0].connector||this.endpoints[1].connector||a.connector||w.Defaults.Connector||new w.Connectors.Bezier;this.paintStyle=this.endpoints[0].connectionStyle||this.endpoints[1].connectionStyle||a.paintStyle||w.Defaults.PaintStyle;I(this.sourceId);I(this.targetId);c=k[this.sourceId];var g=z[this.sourceId];c=this.endpoints[0].anchor.compute([c.left,c.top],g);this.endpoints[0].paint(c); c=k[this.targetId];g=z[this.targetId];c=this.endpoints[1].anchor.compute([c.left,c.top],g);this.endpoints[1].paint(c);var n=V(w.connectorClass);this.canvas=n;this.paint=function(o,t,r){d&&d.debug("Painting Connection; element in motion is "+o+"; ui is ["+t+"]; recalc is ["+r+"]");var u=o!=this.sourceId,x=u?this.sourceId:this.targetId,v=u?0:1,B=u?1:0;if(this.canvas.getContext){I(o,t,r);r&&I(x);t=k[o];r=k[x];o=z[o];var m=z[x];x=n.getContext("2d");var O=this.endpoints[B].anchor.compute([t.left,t.top], o,[r.left,r.top],m);this.endpoints[B].anchor.getOrientation();t=this.endpoints[v].anchor.compute([r.left,r.top],m,[t.left,t.top],o);this.endpoints[v].anchor.getOrientation();v=this.connector.compute(O,t,this.endpoints[B].anchor,this.endpoints[v].anchor,this.paintStyle.lineWidth);w.sizeCanvas(n,v[0],v[1],v[2],v[3]);$.extend(x,this.paintStyle);if(this.paintStyle.gradient&&!h){u=u?x.createLinearGradient(v[4],v[5],v[6],v[7]):x.createLinearGradient(v[6],v[7],v[4],v[5]);for(B=0;B=0&&b.connections.splice(s,1)};this.isFloating=function(){return u!=null};var x=U();this.isFull=function(){return t<1?false:b.connections.length>=t};this.paint=function(s,G,D){d&&d.debug("Painting Endpoint with elementId ["+ o+"]; anchorPoint is ["+s+"]");if(s==null){s=k[o];var C=z[o];if(s==null||C==null){I(o);s=k[o];C=z[o]}s=b.anchor.compute([s.left,s.top],C)}c.paint(s,b.anchor.getOrientation(),D||b.canvas,g,G||g)};if(a.isSource&&n.draggable){var v=null,B=null,m=null,O=false,L=null,A=a.dragOptions||{};A=$.extend({opacity:0.5,revert:true,helper:"clone"},A);A.start=K(A.start,function(){v=document.createElement("div");x.append(v);B=new String((new Date).getTime());$(v,x).attr("id",B);I(B);$(b.canvas,x).attr("dragId",B); $(b.canvas,x).attr("elId",o);var s=new ba({reference:b.anchor});u=new Q({style:g,endpoint:c,anchor:s,source:v});m=b.connections.length==0||b.connections.length=4)c.orientation=[arguments[2],arguments[3]];if(arguments.length==6)c.offsets=[arguments[4],arguments[5]]}return new aa(c)},repaint:function(a){var b=function(g){g=typeof g=="string"?$("#"+g):g;M(g)};if(typeof a=="object")for(var c=0;c< a.length;c++)b(a[c]);else b(a)},repaintEverything:function(){for(var a in f)M($("#"+a))},removeEndpoint:function(a,b){f[a]&&W(f,a,b)&&J(b.canvas)},setAutomaticRepaint:function(a){l=a},setDefaultNewCanvasSize:function(a){H=a},setDraggable:function(a,b){return T(a,function(c,g){q[g]=b;c.draggable&&c.draggable("option","disabled",!b)})},setDraggableByDefault:function(a){y=a},setDebugLog:function(a){d=a},setRepaintFunction:function(a){e=a},show:function(a){X(a,"block")},sizeCanvas:function(a,b,c,g,n){a.style.height= n+"px";a.height=n;a.style.width=g+"px";a.width=g;a.style.left=b+"px";a.style.top=c+"px"},getTestHarness:function(){return{endpointCount:function(a){return(a=f[a])?a.length:0}}},toggle:Y,toggleVisible:Y,toggleDraggable:function(a){return T(a,function(b,c){var g=q[c]==null?y:q[c];g=!g;q[c]=g;b.draggable("option","disabled",!g);return g})},unload:function(){delete f;delete k;delete z;delete p;delete q;document.body.removeChild(E)}}})(); (function(j){j.fn.plumb=function(h){h=j.extend({},h);return this.each(function(){var d=j.extend({source:j(this)},h);jsPlumb.connect(d)})};j.fn.detach=function(h){return this.each(function(){var d=j(this).attr("id");if(typeof h=="string")h=[h];for(var e=0;ek)k=l;if(e<0){q+=e;e=Math.abs(e);k+=e;F[0]+=e;z+=e;H+=e;d[0]+=e}e=Math.min(Math.min(E,f),Math.min(F[1], d[1]));l=Math.max(Math.max(E,f),Math.max(F[1],d[1]));if(l>p)p=l;if(e<0){y+=e;e=Math.abs(e);p+=e;F[1]+=e;E+=e;f+=e;d[1]+=e}return[q,y,k,p,z,E,H,f,F[0],F[1],d[0],d[1]]};this.paint=function(d,e){e.beginPath();e.moveTo(d[4],d[5]);e.bezierCurveTo(d[8],d[9],d[10],d[11],d[6],d[7]);e.stroke()}};jsPlumb.Endpoints.Dot=function(j){j=j||{radius:10};var h=this;this.radius=j.radius;var d=0.5*this.radius,e=this.radius/3,l=function(i){try{return parseInt(i)}catch(f){if(i.substring(i.length-1)=="%")return parseInt(i.substring(0, i-1))}};this.paint=function(i,f,k,p,q){var y=p.radius||h.radius;jsPlumb.sizeCanvas(k,i[0]-y,i[1]-y,y*2,y*2);i=k.getContext("2d");k=$.extend({},p);if(k.fillStyle==null)k.fillStyle=q.strokeStyle;$.extend(i,k);q=/MSIE/.test(navigator.userAgent)&&!window.opera;if(p.gradient&&!q){q=p.gradient;k=d;var z=e;if(q.offset)k=l(q.offset);if(q.innerRadius)z=l(q.innerRadius);q=[k,z];f=i.createRadialGradient(y,y,y,y+(f[0]==1?q[0]*-1:q[0]),y+(f[1]==1?q[0]*-1:q[0]),q[1]);for(q=0;q