1234567891011121314151617181920212223242526272829303132333435 |
- if(!Array.prototype.indexOf)Array.prototype.indexOf=function(j,h,d){h=+h||0;for(var e=this.length;h<e;h++)if(this[h]===j||d&&this[h]==j)return h;return-1};
- (function(){function j(){l&&e()}var h=/MSIE/.test(navigator.userAgent)&&!window.opera,d=null,e=function(){w.repaintEverything()},l=true,i=null;$(window).bind("resize",function(){i&&clearTimeout(i);i=setTimeout(j,100)});var f={},k=[],p={},q={},y=true,z=[],E=null,H=1200,F=function(a,b,c){var g=a[b];if(g==null){g=[];a[b]=g}g.push(c)},M=function(a,b){var c=$(a).attr("id"),g=f[c];if(g){I(c,b);for(var n=k[c],o=z[c],t=0;t<g.length;t++){var r=g[t],u=g[t].anchor.compute([n.left,n.top],o);r.paint(u);r=r.connections;
- for(u=0;u<r.length;u++)r[u].paint(c,b)}}},T=function(a,b){var c=null;if(typeof a=="object"&&a.length){c=[];for(var g=0;g<a.length;g++){var n=typeof a[g]=="string"?$("#"+a[g]):a[g],o=n.attr("id");c.push(b(n,o))}}else{n=typeof a=="string"?a.indexOf("#")==0?$(a):$("#"+a):a;o=n.attr("id");c=b(n,o)}return c},U=function(){if(E==null){E=document.createElement("div");document.body.appendChild(E);E.className="_jsPlumb_context"}return $(E)},P=function(a,b,c,g){if((c==null?y:c)&&a.draggable){var n=g||w.Defaults.DragOptions,
- o=n.drag||function(){};(function(t,r,u){u=$.extend({drag:u},n);r=q[r];u.disabled=r==null?false:!r;t.draggable(u)})(a,b,function(t,r){M(a,r);$(a).addClass("jsPlumb_dragged");o(t,r)})}},V=function(a){var b=document.createElement("canvas");U().append(b);b.style.position="absolute";if(a)b.className=a;if(/MSIE/.test(navigator.userAgent)&&!window.opera){w.sizeCanvas(b,0,0,H,H);b=G_vmlCanvasManager.initElement(b)}return b},N=function(a,b){var c=f[a];if(c&&c.length)for(var g=0;g<c.length;g++)for(var n=0;n<
- c[g].connections.length;n++)if(b(c[g].connections[n]))return},Z=function(a){for(var b in f)N(b,a)},J=function(a){if(a!=null)try{E.removeChild(a)}catch(b){}},W=function(a,b,c){a=a[b];if(a!=null){c=a.indexOf(c);if(c>=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<this.paintStyle.gradient.stops.length;B++)u.addColorStop(this.paintStyle.gradient.stops[B][0],
- this.paintStyle.gradient.stops[B][1]);x.strokeStyle=u}this.connector.paint(v,x)}};this.repaint=function(){this.paint(this.sourceId,null,true)};P(b.source,b.sourceId,a.draggable,a.dragOptions);P(b.target,b.targetId,a.draggable,a.dragOptions);this.source.resize&&this.source.resize(function(){w.repaint(b.sourceId)})},Q=function(a){a=a||{};a=$.extend({},a);var b=this;b.anchor=a.anchor||w.Anchors.TopCenter;var c=a.endpoint||new w.Endpoints.Dot,g=a.style||w.Defaults.EndpointStyle;this.connectionStyle=a.connectionStyle;
- this.connector=a.connector;var n=a.source,o=$(n).attr("id"),t=a.maxConnections||1;this.canvas=a.canvas||V(w.endpointClass);this.connections=a.connections||[];var r=a.reattach||false,u=null;this.addConnection=function(s){b.connections.push(s)};this.removeConnection=function(s){s=b.connections.indexOf(s);s>=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<t?null:b.connections[0];if(m==null){m=new R({sourceEndpoint:b,targetEndpoint:u,source:$(n),target:$(v,x),anchors:[b.anchor,s],paintStyle:a.connectionStyle,connector:a.connector});b.addConnection(m)}else{O=true;s=m.sourceId==o?0:1;m.floatingAnchorIndex=s;b.removeConnection(m);if(s==0){L=[m.source,m.sourceId];m.source=$(v,x);m.sourceId=B}else{L=
- [m.target,m.targetId];m.target=$(v,x);m.targetId=B}m.suspendedEndpoint=m.endpoints[s];m.endpoints[s]=u}p[B]=m;u.addConnection(m);F(f,B,u)});A.drag=K(A.drag,function(s,G){M($(v,x),G)});A.stop=K(A.stop,function(){W(f,B,u);var s=[u.canvas,v];for(var G in s)J(s[G]);s=m.floatingAnchorIndex==null?1:m.floatingAnchorIndex;if(m.endpoints[s]==u)if(O&&m.suspendedEndpoint)if(r){m.floatingAnchorIndex=null;if(s==0){m.source=L[0];m.sourceId=L[1]}else{m.target=L[0];m.targetId=L[1]}m.endpoints[s]=m.suspendedEndpoint;
- m.suspendedEndpoint.addConnection(m);w.repaint(L[1])}else{m.endpoints[0].removeConnection(m);m.endpoints[1].removeConnection(m);J(m.canvas)}else{J(m.canvas);b.removeConnection(m)}m=null;delete u});$(b.canvas,x).draggable(A)}if(a.isTarget&&n.droppable){A=a.dropOptions||w.Defaults.DropOptions;A=$.extend({},A);A.drop=K(A.drop,function(s,G){var D=$(G.draggable,x).attr("dragId");$(G.draggable,x).attr("elId");var C=p[D],S=C.floatingAnchorIndex==null?1:C.floatingAnchorIndex;if(S==0){C.source=n;C.sourceId=
- o}else{C.target=n;C.targetId=o}C.endpoints[S].removeConnection(C);C.suspendedEndpoint&&C.suspendedEndpoint.removeConnection(C);C.endpoints[S]=b;b.addConnection(C);P(n,o,a.draggable,{});w.repaint($(G.draggable,x).attr("elId"));delete p[D]});A.over=K(A.over,function(s,G){var D=$(G.draggable,x).attr("dragId");D=p[D];D.endpoints[D.floatingAnchorIndex==null?1:D.floatingAnchorIndex].anchor.over(b.anchor)});A.out=K(A.out,function(s,G){var D=$(G.draggable,x).attr("dragId");D=p[D];D.endpoints[D.floatingAnchorIndex==
- null?1:D.floatingAnchorIndex].anchor.out()});$(b.canvas,x).droppable(A)}this.plumb=function(){};return b},w=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"}},connectorClass:"_jsPlumb_connector",endpointClass:"_jsPlumb_endpoint",Anchors:{},Connectors:{},Endpoints:{},addEndpoint:function(a,b){b=$.extend({},
- b);var c=typeof a=="string"?$("#"+a):a,g=$(c).attr("id");b.source=c;I(g);c=new Q(b);F(f,g,c);var n=k[g];g=c.anchor.compute([n.left,n.top],z[g]);c.paint(g);return c},animate:function(a,b,c){a=typeof a=="string"?$("#"+a):a;var g=a.attr("id");c=c||{};c.step=K(c.step,function(){w.repaint(g)});a.animate(b,c)},addEndpoints:function(a,b){for(var c=[],g=0;g<b.length;g++)c.push(w.addEndpoint(a,b[g]));return c},connect:function(a){if(!(a.sourceEndpoint&&a.sourceEndpoint.isFull()))if(!(a.targetEndpoint&&a.targetEndpoint.isFull())){a=
- new R(a);F(f,a.sourceId,a.endpoints[0]);F(f,a.targetId,a.endpoints[1]);a.endpoints[0].addConnection(a);a.endpoints[1].addConnection(a);M(a.source)}},connectEndpoints:function(a){R(a)},detach:function(a,b){N(a,function(c){if(c.sourceId==a&&c.targetId==b||c.targetId==a&&c.sourceId==b){J(c.canvas);c.endpoints[0].removeConnection(c);c.endpoints[1].removeConnection(c);return true}})},detachAll:function(a){N(a,function(b){J(b.canvas);b.endpoints[0].removeConnection(b);b.endpoints[1].removeConnection(b)})},
- detachEverything:function(){Z(function(a){J(a.canvas);a.endpoints[0].removeConnection(a);a.endpoints[1].removeConnection(a)})},hide:function(a){X(a,"none")},makeAnchor:function(a,b){var c={};if(arguments.length==1)$.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 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;e<h.length;e++)jsPlumb.detach(d,h[e])})};j.fn.detachAll=function(){return this.each(function(){var h=j(this).attr("id");jsPlumb.detachAll(h)})};j.fn.addEndpoint=function(h){var d=[];this.each(function(){d.push(jsPlumb.addEndpoint(j(this).attr("id"),
- h))});return d};j.fn.addEndpoints=function(h){var d=[];return this.each(function(){for(var e=jsPlumb.addEndpoints(j(this).attr("id"),h),l=0;l<e.length;l++)d.push(e[l])})};j.fn.removeEndpoint=function(h){this.each(function(){jsPlumb.removeEndpoint(j(this).attr("id"),h)})}})(jQuery);
- (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,
- 1,0,1);jsPlumb.Connectors.Straight=function(){this.compute=function(j,h,d,e,l){d=Math.abs(j[0]-h[0]);e=Math.abs(j[1]-h[1]);var i=0.45*d,f=0.45*e;d*=1.9;e*=1.9;var k=Math.min(j[0],h[0])-i,p=Math.min(j[1],h[1])-f;if(d<2*l){d=2*l;k=j[0]+(h[0]-j[0])/2-l;i=(d-Math.abs(j[0]-h[0]))/2}if(e<2*l){e=2*l;p=j[1]+(h[1]-j[1])/2-l;f=(e-Math.abs(j[1]-h[1]))/2}return[k,p,d,e,j[0]<h[0]?d-i:i,j[1]<h[1]?e-f:f,j[0]<h[0]?i:d-i,j[1]<h[1]?f:e-f]};this.paint=function(j,h){h.beginPath();h.moveTo(j[4],j[5]);h.lineTo(j[6],j[7]);
- h.stroke()}};jsPlumb.Connectors.Bezier=function(j){var h=this;this.majorAnchor=j||150;this.minorAnchor=10;this._findControlPoint=function(d,e,l,i,f){i=i.getOrientation();f=f.getOrientation();var k=[],p=h.majorAnchor,q=h.minorAnchor;if(i[0]!=f[0]||i[1]==f[1]){f[0]==0?k.push(l[0]<e[0]?d[0]+q:d[0]-q):k.push(d[0]+p*f[0]);f[1]==0?k.push(l[1]<e[1]?d[1]+q:d[1]-q):k.push(d[1]+p*i[1])}else{i[0]==0?k.push(e[0]<l[0]?d[0]+q:d[0]-q):k.push(d[0]-p*i[0]);i[1]==0?k.push(e[1]<l[1]?d[1]+q:d[1]-q):k.push(d[1]+p*f[1])}return k};
- this.compute=function(d,e,l,i,f){f=f||0;var k=Math.abs(d[0]-e[0])+f,p=Math.abs(d[1]-e[1])+f,q=Math.min(d[0],e[0])-f/2,y=Math.min(d[1],e[1])-f/2,z=d[0]<e[0]?k-f/2:f/2,E=d[1]<e[1]?p-f/2:f/2,H=d[0]<e[0]?f/2:k-f/2;f=d[1]<e[1]?f/2:p-f/2;var F=h._findControlPoint([z,E],d,e,l,i);d=h._findControlPoint([H,f],e,d,i,l);e=Math.min(Math.min(z,H),Math.min(F[0],d[0]));l=Math.max(Math.max(z,H),Math.max(F[0],d[0]));if(l>k)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<p.gradient.stops.length;q++)f.addColorStop(p.gradient.stops[q][0],
- p.gradient.stops[q][1]);i.fillStyle=f}i.beginPath();i.arc(y,y,y,0,Math.PI*2,true);i.closePath();i.fill()}};jsPlumb.Endpoints.Rectangle=function(j){j=j||{width:20,height:20};var h=this;this.width=j.width;this.height=j.height;this.paint=function(d,e,l,i,f){var k=i.width||h.width,p=i.height||h.height;jsPlumb.sizeCanvas(l,d[0]-k/2,d[1]-p/2,k,p);d=l.getContext("2d");l=$.extend({},i);if(l.fillStyle==null)l.fillStyle=f.strokeStyle;$.extend(d,l);f=/MSIE/.test(navigator.userAgent)&&!window.opera;if(i.gradient&&
- !f){e=d.createLinearGradient(e[0]==1?k:e[0]==0?k/2:0,e[1]==1?p:e[1]==0?p/2:0,e[0]==-1?k:e[0]==0?p/2:0,e[1]==-1?p:e[1]==0?p/2:0);for(f=0;f<i.gradient.stops.length;f++)e.addColorStop(i.gradient.stops[f][0],i.gradient.stops[f][1]);d.fillStyle=e}d.beginPath();d.rect(0,0,k,p);d.closePath();d.fill()}};jsPlumb.Endpoints.Image=function(j){var h=this;this.img=new Image;this.img.onload=function(){h.ready=true};this.img.src=j.url;var d=function(e,l,i,f){l=h.img.width||f.width;f=h.img.height||f.height;jsPlumb.sizeCanvas(i,
- e[0]-l/2,e[1]-f/2,l,f);i.getContext("2d").drawImage(h.img,0,0)};this.paint=function(e,l,i,f,k){h.ready?d(e,l,i,f,k):window.setTimeout(function(){h.paint(e,l,i,f,k)},200)}}})();
|