12345678910111213141516171819202122 |
- if(!Array.prototype.indexOf)Array.prototype.indexOf=function(o,m,r){m=+m||0;for(var q=this.length;m<q;m++)if(this[m]===o||r&&this[m]==o)return m;return-1};
- (function(){var o={},m=[],r=[],q=1200,v=function(a,e){$.extend(a,e)},z=function(a,e){a=a.attr("id");for(var b=o[a],c=0;c<b.length;c++)b[c].paint(a,e)},x=function(a,e){a=o[a];for(var b=0;b<a.length;b++){a[b].canvas.style.display=e;if(a[b].drawEndpoints){a[b].sourceEndpointCanvas.style.display=e;a[b].targetEndpointCanvas.style.display=e}}},y=function(a){var e=document.createElement("canvas");document.body.appendChild(e);e.style.position="absolute";if(a)e.className=a;if(/MSIE/.test(navigator.userAgent)&&
- !window.opera){l.sizeCanvas(e,0,0,q,q);e=G_vmlCanvasManager.initElement(e)}return e},w=function(a){a!=null&&document.body.removeChild(a)},u=function(a){var e=this;this.x=a.x||0;this.y=a.y||0;this.orientation=a.orientation||[0,0];this.offsets=a.offsets||[0,0];this.compute=function(b,c){return[b[0]+e.x*c[0]+e.offsets[0],b[1]+e.y*c[1]+e.offsets[1]]}},l=window.jsPlumb={connectorClass:"_jsPlumb_connector",endpointClass:"_jsPlumb_endpoint",DEFAULT_PAINT_STYLE:{lineWidth:10,strokeStyle:"red"},DEFAULT_ENDPOINT_STYLE:{fillStyle:null},
- DEFAULT_ENDPOINT_STYLES:[null,null],DEFAULT_DRAG_OPTIONS:{},DEFAULT_CONNECTOR:null,DEFAULT_ENDPOINT:null,DEFAULT_ENDPOINTS:[null,null],Anchors:{TopCenter:new u({x:0.5,y:0,orientation:[0,-1]}),BottomCenter:new u({x:0.5,y:1,orientation:[0,1]}),LeftMiddle:new u({x:0,y:0.5,orientation:[-1,0]}),RightMiddle:new u({x:1,y:0.5,orientation:[1,0]}),Center:new u({x:0.5,y:0.5,orientation:[0,0]}),TopRight:new u({x:1,y:0,orientation:[0,-1]}),BottomRight:new u({x:1,y:1,orientation:[0,1]}),TopLeft:new u({x:0,y:0,
- orientation:[0,-1]}),BottomLeft:new u({x:0,y:1,orientation:[0,1]})},Connectors:{Straight:function(){this.compute=function(a,e,b,c,f){b=Math.abs(a[0]-e[0]);c=Math.abs(a[1]-e[1]);var h=0.45*b,d=0.45*c;b*=1.9;c*=1.9;var g=Math.min(a[0],e[0])-h,i=Math.min(a[1],e[1])-d;if(b<2*f){b=2*f;g=a[0]+(e[0]-a[0])/2-f;h=(b-Math.abs(a[0]-e[0]))/2}if(c<2*f){c=2*f;i=a[1]+(e[1]-a[1])/2-f;d=(c-Math.abs(a[1]-e[1]))/2}return[g,i,b,c,a[0]<e[0]?b-h:h,a[1]<e[1]?c-d:d,a[0]<e[0]?h:b-h,a[1]<e[1]?d:c-d]};this.paint=function(a,
- e){e.beginPath();e.moveTo(a[4],a[5]);e.lineTo(a[6],a[7]);e.stroke()}},Bezier:function(a){var e=this;this.majorAnchor=a||150;this.minorAnchor=10;this._findControlPoint=function(b,c,f,h,d){var g=[],i=e.majorAnchor,n=e.minorAnchor;h.orientation[0]==0?g.push(c[0]<f[0]?b[0]+n:b[0]-n):g.push(b[0]-i*h.orientation[0]);h.orientation[1]==0?g.push(c[1]<f[1]?b[1]+n:b[1]-n):g.push(b[1]+i*d.orientation[1]);return g};this.compute=function(b,c,f,h,d){d=d||0;var g=Math.abs(b[0]-c[0])+d,i=Math.abs(b[1]-c[1])+d,n=Math.min(b[0],
- c[0])-d/2,j=Math.min(b[1],c[1])-d/2,k=b[0]<c[0]?g-d/2:d/2,s=b[1]<c[1]?i-d/2:d/2,p=b[0]<c[0]?d/2:g-d/2;d=b[1]<c[1]?d/2:i-d/2;var t=e._findControlPoint([k,s],b,c,f,h);b=e._findControlPoint([p,d],c,b,h,f);c=Math.min(k,p);f=Math.min(t[0],b[0]);c=Math.min(c,f);f=Math.max(k,p);h=Math.max(t[0],b[0]);f=Math.max(f,h);if(f>g)g=f;if(c<0){n+=c;c=Math.abs(c);g+=c;t[0]+=c;k+=c;p+=c;b[0]+=c}c=Math.min(s,d);f=Math.min(t[1],b[1]);c=Math.min(c,f);f=Math.max(s,d);h=Math.max(t[1],b[1]);f=Math.max(f,h);if(f>i)i=f;if(c<
- 0){j+=c;c=Math.abs(c);i+=c;t[1]+=c;s+=c;d+=c;b[1]+=c}return[n,j,g,i,k,s,p,d,t[0],t[1],b[0],b[1]]};this.paint=function(b,c){c.beginPath();c.moveTo(b[4],b[5]);c.bezierCurveTo(b[8],b[9],b[10],b[11],b[6],b[7]);c.stroke()}}},Endpoints:{Dot:function(a){a=a||{radius:10};var e=this;this.radius=a.radius;var b=0.5*this.radius,c=this.radius/3,f=function(d){try{return parseInt(d)}catch(g){if(d.substring(d.length-1)=="%")return parseInt(d.substring(0,d-1))}},h=function(d){var g=b,i=c;if(d.offset)g=f(d.offset);
- if(d.innerRadius)i=f(d.innerRadius);return[g,i]};this.paint=function(d,g,i,n,j){var k=n.radius||e.radius;l.sizeCanvas(i,d[0]-k,d[1]-k,k*2,k*2);d=i.getContext("2d");i={};v(i,n);if(i.fillStyle==null)i.fillStyle=j.strokeStyle;v(d,i);j=/MSIE/.test(navigator.userAgent)&&!window.opera;if(n.gradient&&!j){j=h(n.gradient);g=d.createRadialGradient(k,k,k,k+(g[0]==1?j[0]*-1:j[0]),k+(g[1]==1?j[0]*-1:j[0]),j[1]);for(j=0;j<n.gradient.stops.length;j++)g.addColorStop(n.gradient.stops[j][0],n.gradient.stops[j][1]);
- d.fillStyle=g}d.beginPath();d.arc(k,k,k,0,Math.PI*2,true);d.closePath();d.fill()}},Rectangle:function(a){a=a||{width:20,height:20};var e=this;this.width=a.width;this.height=a.height;this.paint=function(b,c,f,h,d){var g=h.width||e.width,i=h.height||e.height;l.sizeCanvas(f,b[0]-g/2,b[1]-i/2,g,i);b=f.getContext("2d");f={};v(f,h);if(f.fillStyle==null)f.fillStyle=d.strokeStyle;v(b,f);d=/MSIE/.test(navigator.userAgent)&&!window.opera;if(h.gradient&&!d){c=b.createLinearGradient(c[0]==1?g:c[0]==0?g/2:0,c[1]==
- 1?i:c[1]==0?i/2:0,c[0]==-1?g:c[0]==0?i/2:0,c[1]==-1?i:c[1]==0?i/2:0);for(d=0;d<h.gradient.stops.length;d++)c.addColorStop(h.gradient.stops[d][0],h.gradient.stops[d][1]);b.fillStyle=c}b.beginPath();b.rect(0,0,g,i);b.closePath();b.fill()}},Image:function(a){var e=this;this.img=new Image;this.img.onload=function(){e.ready=true};this.img.src=a.url;var b=function(c,f,h,d){f=e.img.width||d.width;d=e.img.height||d.height;l.sizeCanvas(h,c[0]-f/2,c[1]-d/2,f,d);h.getContext("2d").drawImage(e.img,0,0)};this.paint=
- function(c,f,h,d,g){e.ready?b(c,f,h,d,g):window.setTimeout(function(){e.paint(c,f,h,d,g)},200)}}},connect:function(a){a=new A(a);o[a.sourceId+"_"+a.targetId]=a;var e=function(b,c){var f=o[b];if(f==null){f=[];o[b]=f}f.push(c)};e(a.sourceId,a);e(a.targetId,a)},detach:function(a,e){for(var b=o[a],c=-1,f=0;f<b.length;f++)if(b[f].sourceId==a&&b[f].targetId==e||b[f].targetId==a&&b[f].sourceId==e){w(b[f].canvas);if(b[f].drawEndpoints){w(b[f].targetEndpointCanvas);w(b[f].sourceEndpointCanvas)}c=f;break}c!=
- -1&&b.splice(c,1)},detachAll:function(a){for(var e=o[a],b=0;b<e.length;b++){w(e[b].canvas);if(e[b].drawEndpoints){w(e[b].targetEndpointCanvas);w(e[b].sourceEndpointCanvas)}}o[a]=[]},hide:function(a){x(a,"none")},makeAnchor:function(a,e){var b={};if(arguments.length==1)$.extend(b,a);else{b={x:a,y:e};if(arguments.length>=4)b.orientation=[arguments[2],arguments[3]];if(arguments.length==6)b.offsets=[arguments[4],arguments[5]]}return new u(b)},repaint:function(a){var e=function(f,h){var d=o[h];f={absolutePosition:f.offset()};
- for(var g=0;g<d.length;g++)d[g].paint(h,f,true)},b=function(f){f=typeof f=="string"?$("#"+f):f;var h=f.attr("id");e(f,h)};if(typeof a=="object")for(var c=0;c<a.length;c++)b(a[c]);else b(a)},setDefaultNewCanvasSize:function(a){q=a},show:function(a){x(a,"block")},sizeCanvas:function(a,e,b,c,f){a.style.height=f+"px";a.height=f;a.style.width=c+"px";a.width=c;a.style.left=e+"px";a.style.top=b+"px"},toggle:function(a){var e=o[a];if(e.length>0)x(a,"none"==e[0].canvas.style.display?"block":"none")}},A=function(a){var e=
- 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.drawEndpoints=a.drawEndpoints!=null?a.drawEndpoints:true;this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.anchors=a.anchors||l.DEFAULT_ANCHORS||[l.Anchors.BottomCenter,l.Anchors.TopCenter];this.connector=a.connector||l.DEFAULT_CONNECTOR||new l.Connectors.Bezier;this.paintStyle=
- a.paintStyle||l.DEFAULT_PAINT_STYLE;this.endpoints=[];if(!a.endpoints)a.endpoints=[null,null];this.endpoints[0]=a.endpoints[0]||a.endpoint||l.DEFAULT_ENDPOINTS[0]||l.DEFAULT_ENDPOINT||new l.Endpoints.Dot;this.endpoints[1]=a.endpoints[1]||a.endpoint||l.DEFAULT_ENDPOINTS[1]||l.DEFAULT_ENDPOINT||new l.Endpoints.Dot;this.endpointStyles=[];if(!a.endpointStyles)a.endpointStyles=[null,null];this.endpointStyles[0]=a.endpointStyles[0]||a.endpointStyle||l.DEFAULT_ENDPOINT_STYLES[0]||l.DEFAULT_ENDPOINT_STYLE;
- this.endpointStyles[1]=a.endpointStyles[1]||a.endpointStyle||l.DEFAULT_ENDPOINT_STYLES[1]||l.DEFAULT_ENDPOINT_STYLE;m[this.sourceId]=this.source.offset();r[this.sourceId]=[this.source.outerWidth(),this.source.outerHeight()];m[this.targetId]=this.target.offset();r[this.targetId]=[this.target.outerWidth(),this.target.outerHeight()];var b=y(l.connectorClass);this.canvas=b;if(this.drawEndpoints){this.sourceEndpointCanvas=y(l.endpointClass);this.targetEndpointCanvas=y(l.endpointClass);if(this.endpointsOnTop){$(this.sourceEndpointCanvas).css("zIndex",
- this.source.css("zIndex")+1);$(this.targetEndpointCanvas).css("zIndex",this.target.css("zIndex")+1)}}this.paint=function(h,d,g){var i=h!=this.sourceId,n=i?this.sourceId:this.targetId,j=i?0:1,k=i?1:0;if(this.canvas.getContext){d=d!=null?d.absolutePosition:$("#"+h).offset();m[h]=d;var s=m[n];if(g){g=$("#"+h);var p=$("#"+n);r[h]=[g.outerWidth(),g.outerHeight()];r[n]=[p.outerWidth(),p.outerHeight()]}p=r[h];var t=r[n];g=b.getContext("2d");n=this.anchors[k].compute([d.left,d.top],p,[s.left,s.top],t);h=
- this.anchors[k].orientation;d=this.anchors[j].compute([s.left,s.top],t,[d.left,d.top],p);s=this.anchors[j].orientation;j=this.connector.compute(n,d,this.anchors[k],this.anchors[j],this.paintStyle.lineWidth);l.sizeCanvas(b,j[0],j[1],j[2],j[3]);v(g,this.paintStyle);k=/MSIE/.test(navigator.userAgent)&&!window.opera;if(this.paintStyle.gradient&&!k){k=i?g.createLinearGradient(j[4],j[5],j[6],j[7]):g.createLinearGradient(j[6],j[7],j[4],j[5]);for(p=0;p<this.paintStyle.gradient.stops.length;p++)k.addColorStop(this.paintStyle.gradient.stops[p][0],
- this.paintStyle.gradient.stops[p][1]);g.strokeStyle=k}this.connector.paint(j,g);if(this.drawEndpoints){j=i?this.sourceEndpointCanvas:this.targetEndpointCanvas;this.endpoints[i?1:0].paint(n,h,i?this.targetEndpointCanvas:this.sourceEndpointCanvas,this.endpointStyles[i?1:0]||this.paintStyle,this.paintStyle);this.endpoints[i?0:1].paint(d,s,j,this.endpointStyles[i?0:1]||this.paintStyle,this.paintStyle)}}};if(a.draggable==null?true:a.draggable){var c=a.dragOptions||l.DEFAULT_DRAG_OPTIONS,f=c.drag||function(){};
- a=function(h,d){var g={};for(var i in c)g[i]=c[i];g.drag=d;h.draggable(g)};a(this.source,function(h,d){z(e.source,d);f(h,d)});a(this.target,function(h,d){z(e.target,d);f(h,d)})}this.source.resize&&this.source.resize(function(){l.repaint(e.sourceId)});this.source.offset();this.paint(this.sourceId,{absolutePosition:this.source.offset()})}})();
- (function(o){o.fn.plumb=function(m){m=o.extend({},m);return this.each(function(){var r=o(this),q={};q.source=r;for(var v in m)q[v]=m[v];jsPlumb.connect(q)})};o.fn.detach=function(m){return this.each(function(){var r=o(this).attr("id");if(typeof m=="string")m=[m];for(var q=0;q<m.length;q++)jsPlumb.detach(r,m[q])})};o.fn.detachAll=function(){return this.each(function(){var m=o(this).attr("id");jsPlumb.detachAll(m)})}})(jQuery);
|