You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4 lines
122 KiB
Plaintext
4 lines
122 KiB
Plaintext
11 months ago
|
jsPlumbUtil={isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},isString:function(t){return typeof t==="string"},isBoolean:function(t){return typeof t==="boolean"},isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},isDate:function(t){return Object.prototype.toString.call(t)==="[object Date]"},isFunction:function(t){return Object.prototype.toString.call(t)==="[object Function]"},clone:function(t){if(this.isString(t)){return new String(t)}else{if(this.isBoolean(t)){return new Boolean(t)}else{if(this.isDate(t)){return new Date(t.getTime())}else{if(this.isFunction(t)){return t}else{if(this.isArray(t)){var e=[];for(var n=0;n<t.length;n++){e.push(this.clone(t[n]))}return e}else{if(this.isObject(t)){var e={};for(var n in t){e[n]=this.clone(t[n])}return e}else{return t}}}}}}},merge:function(t,e){var n=this.clone(t);for(var r in e){if(n[r]==null||this.isString(e[r])||this.isBoolean(e[r])){n[r]=e[r]}else{if(this.isArray(e[r])&&this.isArray(n[r])){var i=[];i.push.apply(i,n[r]);i.push.apply(i,e[r]);n[r]=i}else{if(this.isObject(n[r])&&this.isObject(e[r])){for(var o in e[r]){n[r][o]=e[r][o]}}}}}return n},convertStyle:function(t,e){if("transparent"===t){return t}var n=t,r=function(t){return t.length==1?"0"+t:t},i=function(t){return r(Number(t).toString(16))},o=/(rgb[a]?\()(.*)(\))/;if(t.match(o)){var a=t.match(o)[2].split(",");n="#"+i(a[0])+i(a[1])+i(a[2]);if(!e&&a.length==4){n=n+i(a[3])}}return n},gradient:function(t,e){t=jsPlumbUtil.isArray(t)?t:[t.x,t.y];e=jsPlumbUtil.isArray(e)?e:[e.x,e.y];return(e[1]-t[1])/(e[0]-t[0])},normal:function(t,e){return-1/jsPlumbUtil.gradient(t,e)},lineLength:function(t,e){t=jsPlumbUtil.isArray(t)?t:[t.x,t.y];e=jsPlumbUtil.isArray(e)?e:[e.x,e.y];return Math.sqrt(Math.pow(e[1]-t[1],2)+Math.pow(e[0]-t[0],2))},segment:function(t,e){t=jsPlumbUtil.isArray(t)?t:[t.x,t.y];e=jsPlumbUtil.isArray(e)?e:[e.x,e.y];if(e[0]>t[0]){return e[1]>t[1]?2:1}else{return e[1]>t[1]?3:4}},intersects:function(t,e){var n=t.x,r=t.x+t.w,i=t.y,o=t.y+t.h,a=e.x,s=e.x+e.w,l=e.y,u=e.y+e.h;return n<=a&&a<=r&&i<=l&&l<=o||n<=s&&s<=r&&i<=l&&l<=o||n<=a&&a<=r&&i<=u&&u<=o||n<=s&&a<=r&&i<=u&&u<=o||a<=n&&n<=s&&l<=i&&i<=u||a<=r&&r<=s&&l<=i&&i<=u||a<=n&&n<=s&&l<=o&&o<=u||a<=r&&n<=s&&l<=o&&o<=u},segmentMultipliers:[null,[1,-1],[1,1],[-1,1],[-1,-1]],inverseSegmentMultipliers:[null,[-1,-1],[-1,1],[1,1],[1,-1]],pointOnLine:function(t,e,n){var r=jsPlumbUtil.gradient(t,e),i=jsPlumbUtil.segment(t,e),o=n>0?jsPlumbUtil.segmentMultipliers[i]:jsPlumbUtil.inverseSegmentMultipliers[i],a=Math.atan(r),s=Math.abs(n*Math.sin(a))*o[1],l=Math.abs(n*Math.cos(a))*o[0];return{x:t.x+l,y:t.y+s}},perpendicularLineTo:function(t,e,n){var r=jsPlumbUtil.gradient(t,e),i=Math.atan(-1/r),o=n/2*Math.sin(i),a=n/2*Math.cos(i);return[{x:e.x+a,y:e.y+o},{x:e.x-a,y:e.y-o}]},findWithFunction:function(t,e){if(t){for(var n=0;n<t.length;n++){if(e(t[n])){return n}}}return-1},indexOf:function(t,e){return jsPlumbUtil.findWithFunction(t,function(t){return t==e})},removeWithFunction:function(t,e){var n=jsPlumbUtil.findWithFunction(t,e);if(n>-1){t.splice(n,1)}return n!=-1},remove:function(t,e){var n=jsPlumbUtil.indexOf(t,e);if(n>-1){t.splice(n,1)}return n!=-1},addWithFunction:function(t,e,n){if(jsPlumbUtil.findWithFunction(t,n)==-1){t.push(e)}},addToList:function(t,e,n){var r=t[e];if(r==null){r=[],t[e]=r}r.push(n);return r},EventGenerator:function(){var t={},e=this;var n=["ready"];this.bind=function(n,r){jsPlumbUtil.addToList(t,n,r);return e};this.fire=function(r,i,o){if(t[r]){for(var a=0;a<t[r].length;a++){if(jsPlumbUtil.findWithFunction(n,function(t){return t===r})!=-1){t[r][a](i,o)}else{try{t[r][a](i,o)}catch(s){jsPlumbUtil.log("jsPlumb: fire failed for event "+r+" : "+s)}}}}return e};this.unbind=function(n){if(n){delete t[n]}else{t={}}return e};this.getListener=function(e){return t[e]}},logEnabled:true,log:function(){if(jsPlumbUtil.logEnabled&&typeof console!="undefined"){try{var t=arguments[arguments.length-1];console.log(t)}catch(e){}}},group:function(t){if(jsPlumbUtil.logEnabled&&typeof console!="undefined"){console.group(t)}},g
|
||
|
};this.makeDynamicAnchor=function(t,e){return new tn(t,e)};var Te={},_e={},Ue={},Fe={},He=function(t,e){t.paintStyle=t.paintStyle||b.Defaults.EndpointStyles[e]||b.Defaults.EndpointStyle||M.Defaults.EndpointStyles[e]||M.Defaults.EndpointStyle;t.hoverPaintStyle=t.hoverPaintStyle||b.Defaults.EndpointHoverStyles[e]||b.Defaults.EndpointHoverStyle||M.Defaults.EndpointHoverStyles[e]||M.Defaults.EndpointHoverStyle;t.anchor=t.anchor||b.Defaults.Anchors[e]||b.Defaults.Anchor||M.Defaults.Anchors[e]||M.Defaults.Anchor;t.endpoint=t.endpoint||b.Defaults.Endpoints[e]||b.Defaults.Endpoint||M.Defaults.Endpoints[e]||M.Defaults.Endpoint};this.makeTarget=function(t,e,n){var r=M.extend({_jsPlumb:b},n);M.extend(r,e);He(r,1);var i=M.CurrentLibrary,o=r.scope||b.Defaults.Scope,a=!(r.deleteEndpointsOnDetach===false),s=r.maxConnections||-1,l=r.onMaxConnections;_doOne=function(t){var e=me(t);Te[e]=r;Ue[e]=r.uniqueEndpoint,Fe[e]=s,Ge[e]=true,proxyComponent=new x(r);var n=M.extend({},r.dropOptions||{}),u=function(){var n=M.CurrentLibrary.getDropEvent(arguments),o=b.select({target:e}).length;b.currentlyDragging=false;var s=v(i.getDragObject(arguments)),u=c(s,"dragId"),f=c(s,"originalScope"),h=N[u],p=h.endpoints[0],d=r.endpoint?M.extend({},r.endpoint):{};if(!Ge[e]||Fe[e]>0&&o>=Fe[e]){if(l){l({element:t,connection:h},n)}return false}p.anchor.locked=false;if(f){i.setDragScope(s,f)}var y=proxyComponent.isDropAllowed(h.sourceId,me(t),h.scope,h,null);if(h.endpointsToDeleteOnDetach){if(p===h.endpointsToDeleteOnDetach[0]){h.endpointsToDeleteOnDetach[0]=null}else{if(p===h.endpointsToDeleteOnDetach[1]){h.endpointsToDeleteOnDetach[1]=null}}}if(h.suspendedEndpoint){h.targetId=h.suspendedEndpoint.elementId;h.target=i.getElementObject(h.suspendedEndpoint.elementId);h.endpoints[1]=h.suspendedEndpoint}if(y){p.detach(h,false,true,false);var P=_e[e]||b.addEndpoint(t,r);if(r.uniqueEndpoint){_e[e]=P}P._makeTargetCreator=true;if(P.anchor.positionFinder!=null){var C=i.getUIPosition(arguments,b.getZoom()),j=m(t,b),E=g(t),x=P.anchor.positionFinder(C,j,E,P.anchor.constructorParams);P.anchor.x=x[0];P.anchor.y=x[1]}var D=b.connect({source:p,target:P,scope:f,previousConnection:h,container:h.parent,deleteEndpointsOnDetach:a,doNotFireConnectionEvent:p.endpointWillMoveAfterConnection});if(h.endpoints[1]._makeTargetCreator&&h.endpoints[1].connections.length<2){b.deleteEndpoint(h.endpoints[1])}if(a){D.endpointsToDeleteOnDetach=[p,P]}D.repaint()}else{if(h.suspendedEndpoint){if(p.isReattach){h.setHover(false);h.floatingAnchorIndex=null;h.suspendedEndpoint.addConnection(h);b.repaint(p.elementId)}else{p.detach(h,false,true,true,n)}}}};var f=i.dragEvents.drop;n.scope=n.scope||o;n[f]=ge(n[f],u);i.initDroppable(t,n,true)};t=X(t);var u=t.length&&t.constructor!=String?t:[t];for(var f=0;f<u.length;f++){_doOne(v(u[f]))}return b};this.unmakeTarget=function(t,e){t=M.CurrentLibrary.getElementObject(t);var n=me(t);if(!e){delete Te[n];delete Ue[n];delete Fe[n];delete Ge[n]}return b};this.makeTargets=function(t,e,n){for(var r=0;r<t.length;r++){b.makeTarget(t[r],e,n)}};var Ne={},We={},Ve={},Re={},Be={},ze={},Ge={};this.makeSource=function(t,e,r){var i=M.extend({},r);M.extend(i,e);He(i,0);var o=M.CurrentLibrary,a=i.maxConnections||-1,s=i.onMaxConnections,l=function(t){var r=me(t),l=i.parent,u=l!=null?b.getId(o.getElementObject(l)):r;Ne[u]=i;Ve[u]=i.uniqueEndpoint;Re[u]=true;var c=o.dragEvents.stop,f=o.dragEvents.drag,h=M.extend({},i.dragOptions||{}),p=h.drag,d=h.stop,v=null,m=false;ze[u]=a;h.scope=h.scope||i.scope;h[f]=ge(h[f],function(){if(p){p.apply(this,arguments)}m=false});h[c]=ge(h[c],function(){if(d){d.apply(this,arguments)}b.currentlyDragging=false;if(v.connections.length==0){b.deleteEndpoint(v)}else{o.unbind(v.canvas,"mousedown");var t=i.anchor||b.Defaults.Anchor,e=v.anchor,a=v.connections[0];v.anchor=b.makeAnchor(t,r,b);if(i.parent){var s=o.getElementObject(i.parent);if(s){var l=v.elementId;var u=i.container||b.Defaults.Container||M.Defaults.Container;v.setElement(s,u);v.endpointWillMoveAfterConnection=false;b.anchorManager.rehomeEndpoint(l,s);a.previousConnection=null;n(T[a.scope],function(t
|
||
|
}};this.detachFrom=function(t,e,n){var i=[];for(var o=0;o<r.connections.length;o++){if(r.connections[o].endpoints[1]==t||r.connections[o].endpoints[0]==t){i.push(r.connections[o])}}for(var o=0;o<i.length;o++){if(r.detach(i[o],false,true,e,n)){i[o].setHover(false,false)}}};this.detachFromConnection=function(e){var n=t(r.connections,function(t){return t.id==e.id});if(n>=0){r.connections.splice(n,1)}};this.getElement=function(){return u};this.setElement=function(t,e){var i=me(t);n(_[r.elementId],function(t){return t.id==r.id});u=v(t);g=me(u);r.elementId=g;var o=ie({source:i,container:e}),a=q.getParent(r.canvas);q.removeElement(r.canvas,a);q.appendElement(r.canvas,o);for(var s=0;s<r.connections.length;s++){r.connections[s].moveParent(o);r.connections[s].sourceId=g;r.connections[s].source=u}G(_,i,r)};this.getUuid=function(){return h};this.makeInPlaceCopy=function(){var t=r.anchor.getCurrentLocation(r),e=r.anchor.getOrientation(r),n={compute:function(){return[t[0],t[1]]},getCurrentLocation:function(){return[t[0],t[1]]},getOrientation:function(){return e}};return oe({anchor:n,source:u,paintStyle:this.getPaintStyle(),endpoint:C,_transient:true,scope:r.scope})};this.isConnectedTo=function(t){var e=false;if(t){for(var n=0;n<r.connections.length;n++){if(r.connections[n].endpoints[1]==t){e=true;break}}}return e};this.isFloating=function(){return p!=null};this.connectorSelector=function(){var t=r.connections[0];if(r.isTarget&&t){return t}else{return r.connections.length<O||O==-1?null:t}};this.isFull=function(){return!(r.isFloating()||O<1||r.connections.length<O)};this.setDragAllowedWhenFull=function(t){L=t};this.setStyle=r.setPaintStyle;this.equals=function(t){return this.anchor.equals(t.anchor)};var A=function(t){var e=0;if(t!=null){for(var n=0;n<r.connections.length;n++){if(r.connections[n].sourceId==t||r.connections[n].targetId==t){e=n;break}}}return r.connections[e]};this.paint=function(t){t=t||{};var e=t.timestamp,n=!(t.recalc===false);if(!e||r.timestamp!==e){de({elId:g,timestamp:e,recalc:n});var i=t.offset||F[g];if(i){var o=t.anchorPoint,a=t.connectorPaintStyle;if(o==null){var s=t.dimensions||R[g];if(i==null||s==null){de({elId:g,timestamp:e});i=F[g];s=R[g]}var l={xy:[i.left,i.top],wh:s,element:r,timestamp:e};if(n&&r.anchor.isDynamic&&r.connections.length>0){var u=A(t.elementWithPrecedence),c=u.endpoints[0]==r?1:0,f=c==0?u.sourceId:u.targetId,h=F[f],p=R[f];l.txy=[h.left,h.top];l.twh=p;l.tElement=u.endpoints[c]}o=r.anchor.compute(l)}var d=C.compute(o,r.anchor.getOrientation(r),r.paintStyleInUse,a||r.paintStyleInUse);C.paint(d,r.paintStyleInUse,r.anchor);r.timestamp=e;for(var v=0;v<r.overlays.length;v++){var m=r.overlays[v];if(m.isVisible){r.overlayPlacements[v]=m.draw(r.endpoint,r.paintStyleInUse,d)}}}}};this.repaint=this.paint;this.removeConnection=this.detach;if(M.CurrentLibrary.isDragSupported(u)){var w={id:null,element:null},k=null,H=false,W=null,V=mn(w);var Z=function(){k=r.connectorSelector();var t=true;if(!r.isEnabled()){t=false}if(k==null&&!e.isSource){t=false}if(e.isSource&&r.isFull()&&!L){t=false}if(k!=null&&!k.isDetachable()){t=false}if(t===false){if(M.CurrentLibrary.stopDrag){M.CurrentLibrary.stopDrag()}V.stopDrag();return false}if(k&&!r.isFull()&&e.isSource){k=null}de({elId:g});d=r.makeInPlaceCopy();d.paint();yn(w,r.parent);var n=v(d.canvas),i=m(n,b),o=Qe([i.left,i.top],d.canvas);M.CurrentLibrary.setOffset(w.element,{left:o[0],top:o[1]});if(r.parentAnchor){r.anchor=b.makeAnchor(r.parentAnchor,r.elementId,b)}f(v(r.canvas),"dragId",w.id);f(v(r.canvas),"elId",g);if(e.proxy){r.setPaintStyle(e.proxy.paintStyle)}p=gn(r.getPaintStyle(),r.anchor,C,r.canvas,w.element);if(k==null){r.anchor.locked=true;r.setHover(false,false);k=ee({sourceEndpoint:r,targetEndpoint:p,source:r.endpointWillMoveTo||v(u),target:w.element,anchors:[r.anchor,p.anchor],paintStyle:e.connectorStyle,hoverPaintStyle:e.connectorHoverStyle,connector:e.connector,overlays:e.connectorOverlays,type:r.connectionType,cssClass:r.connectorClass,hoverClass:r.connectorHoverClass})}else{H=true;k.connector.setHover(false,false);te(v(d.canvas),false,true);var a=k.endpoint
|
||
|
}return r},l=function(t,e){for(var n in e){t[n]=e[n]}},u=function(t,e,n,r,i,o){n=n||{};var a=document.createElement("jsplumb:"+t);if(o){i.appendElement(a,r)}else{jsPlumb.CurrentLibrary.appendElement(a,r)}a.className=(n["class"]?n["class"]+" ":"")+"jsplumb_vml";c(a,e);l(a,n);return a},c=function(t,e,n){t.style.left=e[0]+"px";t.style.top=e[1]+"px";t.style.width=e[2]+"px";t.style.height=e[3]+"px";t.style.position="absolute";if(n){t.style.zIndex=n}},f=jsPlumb.vml.convertValue=function(t){return Math.floor(t*o)},h=function(t,e,n,r){if("transparent"===e){r.setOpacity(n,"0.0")}else{r.setOpacity(n,"1.0")}},p=function(t,e,n,r){var i={};if(e.strokeStyle){i.stroked="true";var o=jsPlumbUtil.convertStyle(e.strokeStyle,true);i.strokecolor=o;h(i,o,"stroke",n);i.strokeweight=e.lineWidth+"px"}else{i.stroked="false"}if(e.fillStyle){i.filled="true";var a=jsPlumbUtil.convertStyle(e.fillStyle,true);i.fillcolor=a;h(i,a,"fill",n)}else{i.filled="false"}if(e.dashstyle){if(n.strokeNode==null){n.strokeNode=u("stroke",[0,0,0,0],{dashstyle:e.dashstyle},t,r)}else{n.strokeNode.dashstyle=e.dashstyle}}else{if(e["stroke-dasharray"]&&e.lineWidth){var s=e["stroke-dasharray"].indexOf(",")==-1?" ":",",c=e["stroke-dasharray"].split(s),f="";for(var p=0;p<c.length;p++){f+=Math.floor(c[p]/e.lineWidth)+s}if(n.strokeNode==null){n.strokeNode=u("stroke",[0,0,0,0],{dashstyle:f},t,r)}else{n.strokeNode.dashstyle=f}}}l(t,i)},d=function(){var t=this;jsPlumb.jsPlumbUIComponent.apply(this,arguments);this.opacityNodes={stroke:null,fill:null};this.initOpacityNodes=function(e){t.opacityNodes.stroke=u("stroke",[0,0,1,1],{opacity:"0.0"},e,t._jsPlumb);t.opacityNodes.fill=u("fill",[0,0,1,1],{opacity:"0.0"},e,t._jsPlumb)};this.setOpacity=function(e,n){var r=t.opacityNodes[e];if(r){r.opacity=""+n}};var e=[];this.getDisplayElements=function(){return e};this.appendDisplayElement=function(n,r){if(!r){t.canvas.parentNode.appendChild(n)}e.push(n)}},v=jsPlumb.VmlConnector=function(e){var n=this;n.strokeNode=null;n.canvas=null;d.apply(this,arguments);var r=n._jsPlumb.connectorClass+(e.cssClass?" "+e.cssClass:"");this.paint=function(i,a,s){if(a!=null){var f=n.getPath(i),h={path:f};if(a.outlineColor){var d=a.outlineWidth||1,v=a.lineWidth+2*d,m={strokeStyle:jsPlumbUtil.convertStyle(a.outlineColor),lineWidth:v};for(var g in t){m[g]=a[g]}if(n.bgCanvas==null){h["class"]=r;h.coordsize=i[2]*o+","+i[3]*o;n.bgCanvas=u("shape",i,h,e.parent,n._jsPlumb,true);c(n.bgCanvas,i,n.getZIndex());n.appendDisplayElement(n.bgCanvas,true);n.attachListeners(n.bgCanvas,n);n.initOpacityNodes(n.bgCanvas,["stroke"])}else{h.coordsize=i[2]*o+","+i[3]*o;c(n.bgCanvas,i,n.getZIndex());l(n.bgCanvas,h)}p(n.bgCanvas,m,n)}if(n.canvas==null){h["class"]=r;h.coordsize=i[2]*o+","+i[3]*o;if(n.tooltip){h.label=n.tooltip}n.canvas=u("shape",i,h,e.parent,n._jsPlumb,true);n.appendDisplayElement(n.canvas,true);n.attachListeners(n.canvas,n);n.initOpacityNodes(n.canvas,["stroke"])}else{h.coordsize=i[2]*o+","+i[3]*o;c(n.canvas,i,n.getZIndex());l(n.canvas,h)}p(n.canvas,a,n,n._jsPlumb)}};this.reattachListeners=function(){if(n.canvas){n.reattachListenersForElement(n.canvas,n)}}},m=window.VmlEndpoint=function(t){d.apply(this,arguments);var e=null,n=this,r=null,i=null;n.canvas=document.createElement("div");n.canvas.style.position="absolute";var o=n._jsPlumb.endpointClass+(t.cssClass?" "+t.cssClass:"");t._jsPlumb.appendElement(n.canvas,t.parent);if(n.tooltip){n.canvas.setAttribute("label",n.tooltip)}this.paint=function(t,r,i){var a={};jsPlumb.sizeCanvas(n.canvas,t[0],t[1],t[2],t[3]);if(e==null){a["class"]=o;e=n.getVml([0,0,t[2],t[3]],a,i,n.canvas,n._jsPlumb);n.attachListeners(e,n);n.appendDisplayElement(e,true);n.appendDisplayElement(n.canvas,true);n.initOpacityNodes(e,["fill"])}else{c(e,[0,0,t[2],t[3]]);l(e,a)}p(e,r,n)};this.reattachListeners=function(){if(e){n.reattachListenersForElement(e,n)}}};jsPlumb.Connectors.vml.Bezier=function(){jsPlumb.Connectors.Bezier.apply(this,arguments);v.apply(this,arguments);this.getPath=function(t){return"m"+f(t[4])+","+f(t[5])+" c"+f(t[8])+","+f(t[9])+","+f(t[10])+","+f(t[11])+","+f(t[6])+","+f(t[7])+" e"}};js
|