jsPlumb-1. 3.3-all.js

Summary
jsPlumb-1. 3.3-all.js
Properties
DefaultsThese are the default settings for jsPlumb.
connectorClassThe CSS class to set on Connection elements.
endpointClassThe CSS class to set on Endpoint elements.
overlayClassThe CSS class to set on an Overlay that is an HTML element.
Functions
bindBind to an event on jsPlumb.
clearListenersClears either all listeners, or listeners for some specific event.
addEndpointAdds an Endpoint to a given element or elements.
addEndpointsAdds a list of Endpoints to a given element or elements.
animateThis is a wrapper around the supporting library’s animate function; it injects a call to jsPlumb in the ‘step’ function (creating the ‘step’ function if necessary).
connectEstablishes a Connection between two elements (or Endpoints, which are themselves registered to elements).
deleteEndpointDeletes an Endpoint and removes all Connections it has (which removes the Connections from the other Endpoints involved too)
deleteEveryEndpointDeletes every Endpoint, and their associated Connections, in this instance of jsPlumb.
detachDetaches and then removes a Connection.
detachAllRemoves all an element’s Connections.
detachEveryConnectionRemove all Connections from all elements, but leaves Endpoints in place.
draggableInitialises the draggability of some element or elements.
extendWraps the underlying library’s extend functionality.
getDefaultEndpointTypeReturns the default Endpoint type.
getDefaultConnectionTypeReturns the default Connection type.
getConnectionsGets all or a subset of connections currently managed by this jsPlumb instance.
getAllConnectionsGets all connections, as a map of { scope -> [ connection...
getDefaultScopeGets the default scope for connections and endpoints.
getEndpointGets an Endpoint by UUID
hideSets an element’s connections to be hidden.
makeTargetMakes some DOM element a Connection target, allowing you to drag connections to it without having to register any Endpoints on it first.
readyHelper method to bind a function to jsPlumb’s ready event.
repaintRepaints an element and its connections.
repaintEverythingRepaints all connections.
removeAllEndpointsRemoves all Endpoints associated with a given element.
setAutomaticRepaintSets/unsets automatic repaint on window resize.
setDefaultScopeSets the default scope for Connections and Endpoints.
setDraggableSets whether or not a given element is draggable, regardless of what any jsPlumb command may request.
setDraggableByDefaultSets whether or not elements are draggable by default.
setRepaintFunctionSets the function to fire when the window size has changed and a repaint was fired.
setMouseEventsEnabledSets whether or not mouse events are enabled.
setRenderModeSets render mode: jsPlumb.CANVAS, jsPlumb.SVG or jsPlumb.VML.
showSets an element’s connections to be visible.
sizeCanvasHelper to size a canvas.
toggleVisibleToggles visibility of an element’s Connections.
toggleDraggableToggles draggability (sic?)
unloadUnloads jsPlumb, deleting all storage.
ConnectionThe connecting line between two Endpoints.
Functions and Properties
ConnectionConnection constructor.
sourceIdId of the source element in the connection.
targetIdId of the target element in the connection.
scopeOptional scope descriptor for the connection.
endpointsArray of [source, target] Endpoint objects.
setConnector
connectorThe underlying Connector for this Connection (eg.
overlaysList of Overlays for this Connection.
bindBind to an event on the Connection.
setPaintStyleSets the Connection’s paint style and then repaints the Connection.
setHoverPaintStyleSets the paint style to use when the mouse is hovering over the Connection.
setHoverSets/unsets the hover state of this Connection.
addOverlayAdds an Overlay to the Connection.
getOverlayGets an overlay, by ID.
hideOverlayHides the overlay specified by the given id.
showOverlayShows the overlay specified by the given id.
removeAllOverlaysRemoves all overlays from the Connection, and then repaints.
setLabelSets the Connection’s label.
repaintRepaints the Connection.
EndpointModels an endpoint.
Functions
EndpointEndpoint constructor.
bindBind to an event on the Endpoint.
setPaintStyleSets the Endpoint’s paint style and then repaints the Endpoint.
setHoverPaintStyleSets the paint style to use when the mouse is hovering over the Endpoint.
setHoverSets/unsets the hover state of this Endpoint.
isVisibleReturns whether or not the Endpoint is currently visible.
setVisibleSets whether or not the Endpoint is currently visible.
Properties
canvasThe Endpoint’s Canvas.
connectionsList of Connections this Endpoint is attached to.
scopeScope descriptor for this Endpoint.
Functions
addConnectionAdds a Connection to this Endpoint.
detachDetaches the given Connection from this Endpoint.
detachAllDetaches all Connections this Endpoint has.
detachFromRemoves any connections from this Endpoint that are connected to the given target endpoint.
detachFromConnectionDetach this Endpoint from the Connection, but leave the Connection alive.
getElementReturns the DOM element this Endpoint is attached to.
getUuidReturns the UUID for this Endpoint, if there is one.
isConnectedToReturns whether or not this endpoint is connected to the given Endpoint.
isFullReturns whether or not the Endpoint can accept any more Connections.
setDragAllowedWhenFullSets whether or not connections can be dragged from this Endpoint once it is full.
setStyleSets the paint style of the Endpoint.
paintPaints the Endpoint, recalculating offset and anchor positions if necessary.
Connectors. StraightThe Straight connector draws a simple straight line between the two anchor points.
Connectors. FlowchartProvides ‘flowchart’ connectors, consisting of vertical and horizontal line segments.
Functions
Constructor
Endpoints.DotA round endpoint, with default radius 10 pixels.
Functions
Constructor
Endpoints. RectangleA Rectangular Endpoint, with default size 20x20.
Functions
Constructor
Endpoints. ImageDraws an image as the Endpoint.
Functions
Constructor
Endpoints. BlankAn Endpoint that paints nothing on the screen, and cannot be interacted with using the mouse.
Endpoints. TriangleA triangular Endpoint.
Functions
Constructor
Overlays. ArrowAn arrow overlay, defined by four points: the head, the two sides of the tail, and a ‘foldback’ point at some distance along the length of the arrow that lines from each tail point converge into.
Functions
Constructor
Overlays. PlainArrowA basic arrow.
Functions
ConstructorSee Overlays.Arrow for allowed parameters for this overlay.
Overlays. DiamondA diamond.
Functions
ConstructorSee Overlays.Arrow for allowed parameters for this overlay.
Overlays. LabelA Label overlay.
Functions
Constructor

Properties

Defaults

These are the default settings for jsPlumb.  They are what will be used if you do not supply specific pieces of information to the various API calls.  A convenient way to implement your own look and feel can be to override these defaults by including a script somewhere after the jsPlumb include, but before you make any calls to jsPlumb.

Properties

  • Anchor The default anchor to use for all connections (both source and target).  Default is “BottomCenter”.
  • Anchors The default anchors to use ([source, target]) for all connections.  Defaults are [“BottomCenter”, “BottomCenter”].
  • Connector The default connector definition to use for all connections.  Default is “Bezier”.
  • Container Optional selector or element id that instructs jsPlumb to append elements it creates to a specific element.
  • DragOptions The default drag options to pass in to connect, makeTarget and addEndpoint calls.  Default is empty.
  • DropOptions The default drop options to pass in to connect, makeTarget and addEndpoint calls.  Default is empty.
  • Endpoint The default endpoint definition to use for all connections (both source and target).  Default is “Dot”.
  • Endpoints The default endpoint definitions ([ source, target ]) to use for all connections.  Defaults are [“Dot”, “Dot”].
  • EndpointStyle The default style definition to use for all endpoints.  Default is fillStyle:”#456”.
  • EndpointStyles The default style definitions ([ source, target ]) to use for all endpoints.  Defaults are empty.
  • EndpointHoverStyle The default hover style definition to use for all endpoints.  Default is null.
  • EndpointHoverStyles The default hover style definitions ([ source, target ]) to use for all endpoints.  Defaults are null.
  • HoverPaintStyle The default hover style definition to use for all connections.  Defaults are null.
  • LabelStyle The default style to use for label overlays on connections.
  • LogEnabled Whether or not the jsPlumb log is enabled. defaults to false.
  • Overlays The default overlay definitions.  Defaults to an empty list.
  • MaxConnections The default maximum number of connections for an Endpoint.  Defaults to 1.
  • MouseEventsEnabled Whether or not mouse events are enabled when using the canvas renderer.  Defaults to true.  The idea of this is just to give people a way to prevent all the mouse listeners from activating if they know they won’t need mouse events.
  • PaintStyle The default paint style for a connection.  Default is line width of 8 pixels, with color “#456”.
  • RenderMode What mode to use to paint with.  If you’re on IE<9, you don’t really get to choose this.  You’ll just get VML.  Otherwise, the jsPlumb default is to use Canvas elements.
  • Scope The default “scope” to use for connections.  Scope lets you assign connections to different categories.

connectorClass

The CSS class to set on Connection elements.  This value is a String and can have multiple classes; the entire String is appended as-is.

endpointClass

The CSS class to set on Endpoint elements.  This value is a String and can have multiple classes; the entire String is appended as-is.

overlayClass

The CSS class to set on an Overlay that is an HTML element.  This value is a String and can have multiple classes; the entire String is appended as-is.

Functions

bind

Bind to an event on jsPlumb.

Parameters

eventthe event to bind.  Available events on jsPlumb are:
  • jsPlumbConnection : notification that a new Connection was established.  jsPlumb passes the new Connection to the callback.
  • jsPlumbConnectionDetached : notification that a Connection was detached.  jsPlumb passes the detached Connection to the callback.
  • click : notification that a Connection was clicked.  jsPlumb passes the Connection that was clicked to the callback.
  • dblclick : notification that a Connection was double clicked.  jsPlumb passes the Connection that was double clicked to the callback.
  • endpointClick : notification that an Endpoint was clicked.  jsPlumb passes the Endpoint that was clicked to the callback.
  • endpointDblClick : notification that an Endpoint was double clicked.  jsPlumb passes the Endpoint that was double clicked to the callback.
callbackfunction to callback.  This function will be passed the Connection/Endpoint that caused the event, and also the original event.

clearListeners

Clears either all listeners, or listeners for some specific event.

Parameters

eventoptional. constrains the clear to just listeners for this event.

addEndpoint

this.addEndpoint = function(el,
params,
referenceParams)

Adds an Endpoint to a given element or elements.

Parameters

elElement to add the endpoint to.  Either an element id, a selector representing some element(s), or an array of either of these.
paramsObject containing Endpoint constructor arguments.  For more information, see Endpoint.
referenceParamsObject containing more Endpoint constructor arguments; it will be merged with params by jsPlumb.  You would use this if you had some shared parameters that you wanted to reuse when you added Endpoints to a number of elements.  The allowed values in this object are anything that ‘params’ can contain.  See Endpoint.

Returns

The newly created Endpoint, if el referred to a single element.  Otherwise, an array of newly created Endpoints.

See Also

addEndpoints

addEndpoints

this.addEndpoints = function(el,
endpoints,
referenceParams)

Adds a list of Endpoints to a given element or elements.

Parameters

targetelement to add the Endpoint to.  Either an element id, a selector representing some element(s), or an array of either of these.
endpointsList of objects containing Endpoint constructor arguments. one Endpoint is created for each entry in this list.  See Endpoint’s constructor documentation.
referenceParamsObject containing more Endpoint constructor arguments; it will be merged with params by jsPlumb.  You would use this if you had some shared parameters that you wanted to reuse when you added Endpoints to a number of elements.

Returns

List of newly created Endpoints, one for each entry in the ‘endpoints’ argument.

See Also

addEndpoint

animate

this.animate = function(el,
properties,
options)

This is a wrapper around the supporting library’s animate function; it injects a call to jsPlumb in the ‘step’ function (creating the ‘step’ function if necessary).  This only supports the two-arg version of the animate call in jQuery, the one that takes an ‘options’ object as the second arg.  MooTools has only one method, a two arg one.  Which is handy.  YUI has a one-arg method, so jsPlumb merges ‘properties’ and ‘options’ together for YUI.

Parameters

elElement to animate.  Either an id, or a selector representing the element.
propertiesThe ‘properties’ argument you want passed to the library’s animate call.
optionsThe ‘options’ argument you want passed to the library’s animate call.

Returns

void

connect

this.connect = function(params,
referenceParams)

Establishes a Connection between two elements (or Endpoints, which are themselves registered to elements).

Parameters

paramsObject containing constructor arguments for the Connection.  See Connection’s constructor documentation.
referenceParamsOptional object containing more constructor arguments for the Connection.  Typically you would pass in data that a lot of Connections are sharing here, such as connector style etc, and then use the main params for data specific to this Connection.

Returns

The newly created Connection.

deleteEndpoint

this.deleteEndpoint = function(object)

Deletes an Endpoint and removes all Connections it has (which removes the Connections from the other Endpoints involved too)

Parameters

objecteither an Endpoint object (such as from an addEndpoint call), or a String UUID.

Returns

void

deleteEveryEndpoint

this.deleteEveryEndpoint = function()

Deletes every Endpoint, and their associated Connections, in this instance of jsPlumb.  Does not unregister any event listeners (this is the only difference between this method and jsPlumb.reset).

Returns

void

detach

this.detach = function(source,
target)

Detaches and then removes a Connection.  Takes either (source, target) (the old way, maintained for backwards compatibility), or a params object with various possible values.

Parameters

sourceid or element object of the first element in the Connection.
targetid or element object of the second element in the Connection.
paramsa JS object containing the same parameters as you pass to jsPlumb.connect.  If this is present then neither source nor target should be present; it should be the only argument to the method.  See the docs for Connection’s constructor for information about the parameters allowed in the params object.  Returns: true if successful, false if not.

detachAll

this.detachAllConnections = function(el)

Removes all an element’s Connections.

Parameters

eleither the id of the element, or a selector for the element.

Returns

void

detachEveryConnection

this.detachEveryConnection = function()

Remove all Connections from all elements, but leaves Endpoints in place.

Returns

void

See Also

<removeEveryEndpoint>

draggable

this.draggable = function(el,
options)

Initialises the draggability of some element or elements.  You should use this instead of you library’s draggable method so that jsPlumb can setup the appropriate callbacks.  Your underlying library’s drag method is always called from this method.

Parameters

eleither an element id, a list of element ids, or a selector.
optionsoptions to pass through to the underlying library

Returns

void

extend

this.extend = function(o1,
o2)

Wraps the underlying library’s extend functionality.

Parameters

o1object to extend
o2object to extend o1 with

Returns

o1, extended with all properties from o2.

getDefaultEndpointType

this.getDefaultEndpointType = function()

Returns the default Endpoint type.  Used when someone wants to subclass Endpoint and have jsPlumb return instances of their subclass. you would make a call like this in your class’s constructor: jsPlumb.getDefaultEndpointType().apply(this, arguments);

Returns

the default Endpoint function used by jsPlumb.

getDefaultConnectionType

this.getDefaultConnectionType = function()

Returns the default Connection type.  Used when someone wants to subclass Connection and have jsPlumb return instances of their subclass. you would make a call like this in your class’s constructor: jsPlumb.getDefaultConnectionType().apply(this, arguments);

Returns

the default Connection function used by jsPlumb.

getConnections

this.getConnections = function(options)

Gets all or a subset of connections currently managed by this jsPlumb instance.  If only one scope is passed in to this method, the result will be a list of connections having that scope (passing in no scope at all will result in jsPlumb assuming you want the default scope).  If multiple scopes are passed in, the return value will be a map of { scope -> [ connection...  ] }.

Parameters scope - if the only argument to getConnections is a string, jsPlumb will treat that string as a scope filter, and return a list of connections that are in the given scope. options - if the argument is a JS object, you can specify a finer-grained filter:

  • scope may be a string specifying a single scope, or an array of strings, specifying multiple scopes.
  • source either a string representing an element id, or a selector.  constrains the result to connections having this source.
  • target either a string representing an element id, or a selector.  constrains the result to connections having this target.

getAllConnections

this.getAllConnections = function()

Gets all connections, as a map of { scope -> [ connection...  ] }.

getDefaultScope

this.getDefaultScope = function()

Gets the default scope for connections and endpoints. a scope defines a type of endpoint/connection; supplying a scope to an endpoint or connection allows you to support different types of connections in the same UI. but if you’re only interested in one type of connection, you don’t need to supply a scope. this method will probably be used by very few people; it’s good for testing though.

getEndpoint

Gets an Endpoint by UUID

Parameters

uuidthe UUID for the Endpoint

Returns

Endpoint with the given UUID, null if nothing found.

hide

this.hide = function(el,
changeEndpoints)

Sets an element’s connections to be hidden.

Parameters

eleither the id of the element, or a selector for the element.
changeEndpointswhether not to also hide endpoints on the element. by default this is false.

Returns

void

makeTarget

Makes some DOM element a Connection target, allowing you to drag connections to it without having to register any Endpoints on it first.  When a Connection is established, the endpoint spec that was passed in to this method is used to create a suitable Endpoint (the default will be used if you do not provide one).

Parameters

elstring id or element selector for the element to make a target.
paramsJS object containing parameters: endpoint optional.  specification of an endpoint to create when a connection is created. scope optional.  scope for the drop zone. dropOptions optional. same stuff as you would pass to dropOptions of an Endpoint definition. deleteEndpointsOnDetach optional, defaults to false. whether or not to delete any Endpoints created by a connection to this target if the connection is subsequently detached. this will not remove Endpoints that have had more Connections attached to them after they were created.

ready

this.ready = function(fn)

Helper method to bind a function to jsPlumb’s ready event.

repaint

this.repaint = function(el)

Repaints an element and its connections.  This method gets new sizes for the elements before painting anything.

Parameters

eleither the id of the element or a selector representing the element.

Returns

void

See Also

repaintEverything

repaintEverything

this.repaintEverything = function()

Repaints all connections.

Returns

void

See Also

repaint

removeAllEndpoints

this.removeAllEndpoints = function(el)

Removes all Endpoints associated with a given element.  Also removes all Connections associated with each Endpoint it removes.

Parameters

eleither an element id, or a selector for an element.

Returns

void

See Also

<removeEndpoint>

setAutomaticRepaint

this.setAutomaticRepaint = function(value)

Sets/unsets automatic repaint on window resize.

Parameters

valuewhether or not to automatically repaint when the window is resized.

Returns: void

setDefaultScope

this.setDefaultScope = function(scope)

Sets the default scope for Connections and Endpoints.  A scope defines a type of Endpoint/Connection; supplying a scope to an Endpoint or Connection allows you to support different types of Connections in the same UI.  If you’re only interested in one type of Connection, you don’t need to supply a scope.  This method will probably be used by very few people; it just instructs jsPlumb to use a different key for the default scope.

Parameters

scopescope to set as default.

setDraggable

Sets whether or not a given element is draggable, regardless of what any jsPlumb command may request.

Parameters

eleither the id for the element, or a selector representing the element.

Returns

void

setDraggableByDefault

this.setDraggableByDefault = function(draggable)

Sets whether or not elements are draggable by default.  Default for this is true.

Parameters

draggablevalue to set

Returns

void

setRepaintFunction

this.setRepaintFunction = function(f)

Sets the function to fire when the window size has changed and a repaint was fired.

Parameters

fFunction to execute.

Returns: void

setMouseEventsEnabled

this.setMouseEventsEnabled = function(enabled)

Sets whether or not mouse events are enabled.  Default is true.

Parameters

enabledwhether or not mouse events should be enabled.

Returns

void

setRenderMode

this.setRenderMode = function(mode)

Sets render mode: jsPlumb.CANVAS, jsPlumb.SVG or jsPlumb.VML.  jsPlumb will fall back to VML if it determines that what you asked for is not supported (and that VML is).  If you asked for VML but the browser does not support it, jsPlumb uses SVG.

Returns

the render mode that jsPlumb set, which of course may be different from that requested.

show

this.show = function(el,
changeEndpoints)

Sets an element’s connections to be visible.

Parameters

eleither the id of the element, or a selector for the element.
changeEndpointswhether or not to also change the visible state of the endpoints on the element.  this also has a bearing on other connections on those endpoints: if their other endpoint is also visible, the connections are made visible.

Returns

void

sizeCanvas

this.sizeCanvas = function(canvas,
x,
y,
w,
h)

Helper to size a canvas.  You would typically use this when writing your own Connector or Endpoint implementation.

Parameters

x[int] x position for the Canvas origin
y[int] y position for the Canvas origin
w[int] width of the canvas
h[int] height of the canvas

Returns

void

toggleVisible

Toggles visibility of an element’s Connections.

Parameters

eleither the element’s id, or a selector representing the element.
changeEndpointswhether or not to also toggle the endpoints on the element.

Returns

void, but should be updated to return the current state

toggleDraggable

Toggles draggability (sic?) of an element’s Connections.

Parameters

eleither the element’s id, or a selector representing the element.

Returns

The current draggable state.

unload

this.unload = function()

Unloads jsPlumb, deleting all storage.  You should call this from an onunload attribute on the <body> element.

Returns

void

Connection

The connecting line between two Endpoints.

Summary
Functions and Properties
ConnectionConnection constructor.
sourceIdId of the source element in the connection.
targetIdId of the target element in the connection.
scopeOptional scope descriptor for the connection.
endpointsArray of [source, target] Endpoint objects.
setConnector
connectorThe underlying Connector for this Connection (eg.
overlaysList of Overlays for this Connection.
bindBind to an event on the Connection.
setPaintStyleSets the Connection’s paint style and then repaints the Connection.
setHoverPaintStyleSets the paint style to use when the mouse is hovering over the Connection.
setHoverSets/unsets the hover state of this Connection.
addOverlayAdds an Overlay to the Connection.
getOverlayGets an overlay, by ID.
hideOverlayHides the overlay specified by the given id.
showOverlayShows the overlay specified by the given id.
removeAllOverlaysRemoves all overlays from the Connection, and then repaints.
setLabelSets the Connection’s label.
repaintRepaints the Connection.

Functions and Properties

Connection

var Connection = function(params)

Connection constructor.

Parameters

sourceeither an element id, a selector for an element, or an Endpoint.
targeteither an element id, a selector for an element, or an Endpoint
scopescope descriptor for this connection. optional.
containeroptional id or selector instructing jsPlumb where to attach all the elements it creates for this connection.  you should read the documentation for a full discussion of this.
endpointOptional.  Endpoint definition to use for both ends of the connection.
endpointsOptional.  Array of two Endpoint definitions, one for each end of the Connection.  This and ‘endpoint’ are mutually exclusive parameters.
endpointStyleOptional.  Endpoint style definition to use for both ends of the Connection.
endpointStylesOptional.  Array of two Endpoint style definitions, one for each end of the Connection.  This and ‘endpoint’ are mutually exclusive parameters.
paintStyleParameters defining the appearance of the Connection.  Optional; jsPlumb will use the defaults if you supply nothing here.
hoverPaintStyleParameters defining the appearance of the Connection when the mouse is hovering over it.  Optional; jsPlumb will use the defaults if you supply nothing here (note that the default hoverPaintStyle is null).
overlaysOptional array of Overlay definitions to appear on this Connection.
drawEndpointsif false, instructs jsPlumb to not draw the endpoints for this Connection.  Be careful with this: it only really works when you tell jsPlumb to attach elements to the document body.  Read the documentation for a full discussion of this.

sourceId

Id of the source element in the connection.

targetId

Id of the target element in the connection.

scope

Optional scope descriptor for the connection.

endpoints

Array of [source, target] Endpoint objects.

setConnector

this.setConnector = function(connector,
doNotRepaint)
Sets the Connection’s connector (eg “Bezier”, “Flowchart”, etc).  You pass a Connector definition into this methodthe same thing that you would set as the ‘connector’ property on a jsPlumb.connect call.

Parameters

connectorConnector definition

connector

The underlying Connector for this Connection (eg. a Bezier connector, straight line connector, flowchart connector etc)

overlays

List of Overlays for this Connection.

bind

Bind to an event on the Connection.

Parameters

eventthe event to bind.  Available events on a Connection are:
  • click : notification that a Connection was clicked.
  • dblclick : notification that a Connection was double clicked.
  • mouseenter : notification that the mouse is over a Connection.
  • mouseexit : notification that the mouse exited a Connection.
callbackfunction to callback.  This function will be passed the Connection that caused the event, and also the original event.

setPaintStyle

Sets the Connection’s paint style and then repaints the Connection.

Parameters

styleStyle to use.

setHoverPaintStyle

Sets the paint style to use when the mouse is hovering over the Connection.  This is null by default.  The hover paint style is applied as extensions to the paintStyle; it does not entirely replace it.  This is because people will most likely want to change just one thing when hovering, say the color for example, but leave the rest of the appearance the same.

Parameters

styleStyle to use when the mouse is hovering.
doNotRepaintif true, the Connection will not be repainted.  useful when setting things up initially.

setHover

Sets/unsets the hover state of this Connection.

Parameters

hoverhover state boolean
ignoreAttachedElementsif true, does not notify any attached elements of the change in hover state.  used mostly to avoid infinite loops.

addOverlay

this.addOverlay = function(overlay)

Adds an Overlay to the Connection.

Parameters

overlayOverlay to add.

getOverlay

this.getOverlay = function(id)

Gets an overlay, by ID.  Note: by ID.  You would pass an ‘id’ parameter in to the Overlay’s constructor arguments, and then use that to retrieve it via this method.

hideOverlay

this.hideOverlay = function(id)

Hides the overlay specified by the given id.

showOverlay

this.showOverlay = function(id)

Shows the overlay specified by the given id.

removeAllOverlays

this.removeAllOverlays = function()

Removes all overlays from the Connection, and then repaints.

setLabel

this.setLabel = function(l)

Sets the Connection’s label.

Parameters

llabel to set.  May be a String or a Function that returns a String.

repaint

this.repaint = function()

Repaints the Connection.

Endpoint

Models an endpoint.  Can have 1 to ‘maxConnections’ Connections emanating from it (set maxConnections to -1 to allow unlimited).  Typically, if you use ‘jsPlumb.connect’ to programmatically connect two elements, you won’t actually deal with the underlying Endpoint objects.  But if you wish to support drag and drop Connections, one of the ways you do so is by creating and registering Endpoints using ‘jsPlumb.addEndpoint’, and marking these Endpoints as ‘source’ and/or ‘target’ Endpoints for Connections.

Summary
Functions
EndpointEndpoint constructor.
bindBind to an event on the Endpoint.
setPaintStyleSets the Endpoint’s paint style and then repaints the Endpoint.
setHoverPaintStyleSets the paint style to use when the mouse is hovering over the Endpoint.
setHoverSets/unsets the hover state of this Endpoint.
isVisibleReturns whether or not the Endpoint is currently visible.
setVisibleSets whether or not the Endpoint is currently visible.
Properties
canvasThe Endpoint’s Canvas.
connectionsList of Connections this Endpoint is attached to.
scopeScope descriptor for this Endpoint.
Functions
addConnectionAdds a Connection to this Endpoint.
detachDetaches the given Connection from this Endpoint.
detachAllDetaches all Connections this Endpoint has.
detachFromRemoves any connections from this Endpoint that are connected to the given target endpoint.
detachFromConnectionDetach this Endpoint from the Connection, but leave the Connection alive.
getElementReturns the DOM element this Endpoint is attached to.
getUuidReturns the UUID for this Endpoint, if there is one.
isConnectedToReturns whether or not this endpoint is connected to the given Endpoint.
isFullReturns whether or not the Endpoint can accept any more Connections.
setDragAllowedWhenFullSets whether or not connections can be dragged from this Endpoint once it is full.
setStyleSets the paint style of the Endpoint.
paintPaints the Endpoint, recalculating offset and anchor positions if necessary.

Functions

Endpoint

var Endpoint = function(params)

Endpoint constructor.

Parameters

anchordefinition of the Anchor for the endpoint.  You can include one or more Anchor definitions here; if you include more than one, jsPlumb creates a ‘dynamic’ Anchor, ie. an Anchor which changes position relative to the other elements in a Connection.  Each Anchor definition can be either a string nominating one of the basic Anchors provided by jsPlumb (eg.  “TopCenter”), or a four element array that designates the Anchor’s location and orientation (eg, and this is equivalent to TopCenter, [ 0.5, 0, 0, -1 ]).  To provide more than one Anchor definition just put them all in an array.  You can mix string definitions with array definitions.
endpointoptional Endpoint definition.  This takes the form of either a string nominating one of the basic Endpoints provided by jsPlumb (eg.  “Rectangle”), or an array containing [name,params] for those cases where you don’t wish to use the default values, eg.  [ “Rectangle”, { width:5, height:10 } ].
paintStyleendpoint style, a js object. may be null.
hoverPaintStylestyle to use when the mouse is hovering over the Endpoint.  A js object. may be null; defaults to null.
sourceelement the Endpoint is attached to, of type String (an element id) or element selector.  Required.
canvascanvas element to use. may be, and most often is, null.
containeroptional id or selector instructing jsPlumb where to attach the element it creates for this endpoint.  you should read the documentation for a full discussion of this.
connectionsoptional list of Connections to configure the Endpoint with.
isSourceboolean. indicates the endpoint can act as a source of new connections.  Optional; defaults to false.
maxConnectionsinteger; defaults to 1.  a value of -1 means no upper limit.
dragOptionsif isSource is set to true, you can supply arguments for the underlying library’s drag method.  Optional; defaults to null.
connectorStyleif isSource is set to true, this is the paint style for Connections from this Endpoint.  Optional; defaults to null.
connectorHoverStyleif isSource is set to true, this is the hover paint style for Connections from this Endpoint.  Optional; defaults to null.
connectoroptional Connector type to use.  Like ‘endpoint’, this may be either a single string nominating a known Connector type (eg.  “Bezier”, “Straight”), or an array containing [name, params], eg.  [ “Bezier”, { curviness:160 } ].
connectorOverlaysoptional array of Overlay definitions that will be applied to any Connection from this Endpoint.
isTargetboolean. indicates the endpoint can act as a target of new connections.  Optional; defaults to false.
dropOptionsif isTarget is set to true, you can supply arguments for the underlying library’s drop method with this parameter.  Optional; defaults to null.
reattachoptional boolean that determines whether or not the Connections reattach after they have been dragged off an Endpoint and left floating. defaults to false: Connections dropped in this way will just be deleted.

bind

Bind to an event on the Endpoint.

Parameters

eventthe event to bind.  Available events on an Endpoint are:
  • click : notification that a Endpoint was clicked.
  • dblclick : notification that a Endpoint was double clicked.
  • mouseenter : notification that the mouse is over a Endpoint.
  • mouseexit : notification that the mouse exited a Endpoint.
callbackfunction to callback.  This function will be passed the Endpoint that caused the event, and also the original event.

setPaintStyle

Sets the Endpoint’s paint style and then repaints the Endpoint.

Parameters

styleStyle to use.

setHoverPaintStyle

Sets the paint style to use when the mouse is hovering over the Endpoint.  This is null by default.  The hover paint style is applied as extensions to the paintStyle; it does not entirely replace it.  This is because people will most likely want to change just one thing when hovering, say the color for example, but leave the rest of the appearance the same.

Parameters

styleStyle to use when the mouse is hovering.
doNotRepaintif true, the Endpoint will not be repainted.  useful when setting things up initially.

setHover

Sets/unsets the hover state of this Endpoint.

Parameters

hoverhover state boolean
ignoreAttachedElementsif true, does not notify any attached elements of the change in hover state.  used mostly to avoid infinite loops.

isVisible

this.isVisible = function()

Returns whether or not the Endpoint is currently visible.

setVisible

this.setVisible = function(v,
doNotChangeConnections,
doNotNotifyOtherEndpoint)

Sets whether or not the Endpoint is currently visible.

Parameters

visiblewhether or not the Endpoint should be visible.
doNotChangeConnectionsInstructs jsPlumb to not pass the visible state on to any attached Connections. defaults to false.
doNotNotifyOtherEndpointInstructs jsPlumb to not pass the visible state on to Endpoints at the other end of any attached Connections. defaults to false.

Properties

canvas

The Endpoint’s Canvas.

connections

List of Connections this Endpoint is attached to.

scope

Scope descriptor for this Endpoint.

Functions

addConnection

this.addConnection = function(connection)

Adds a Connection to this Endpoint.

Parameters

connectionthe Connection to add.

detach

this.detach = function(connection,
ignoreTarget)

Detaches the given Connection from this Endpoint.

Parameters

connectionthe Connection to detach.
ignoreTargetoptional; tells the Endpoint to not notify the Connection target that the Connection was detached.  The default behaviour is to notify the target.

detachAll

this.detachAll = function()

Detaches all Connections this Endpoint has.

detachFrom

this.detachFrom = function(targetEndpoint)

Removes any connections from this Endpoint that are connected to the given target endpoint.

Parameters

targetEndpointEndpoint from which to detach all Connections from this Endpoint.

detachFromConnection

this.detachFromConnection = function(connection)

Detach this Endpoint from the Connection, but leave the Connection alive.  Used when dragging.

Parameters

connectionConnection to detach from.

getElement

this.getElement = function()

Returns the DOM element this Endpoint is attached to.

getUuid

this.getUuid = function()

Returns the UUID for this Endpoint, if there is one.  Otherwise returns null.

isConnectedTo

this.isConnectedTo = function(endpoint)

Returns whether or not this endpoint is connected to the given Endpoint.

Parameters

endpointEndpoint to test.

isFull

this.isFull = function()

Returns whether or not the Endpoint can accept any more Connections.

setDragAllowedWhenFull

this.setDragAllowedWhenFull = function(allowed)

Sets whether or not connections can be dragged from this Endpoint once it is full.  You would use this in a UI in which you’re going to provide some other way of breaking connections, if you need to break them at all.  This property is by default true; use it in conjunction with the ‘reattach’ option on a connect call.

Parameters

allowedwhether drag is allowed or not when the Endpoint is full.

setStyle

Sets the paint style of the Endpoint.  This is a JS object of the same form you supply to a jsPlumb.addEndpoint or jsPlumb.connect call.  TODO move setStyle into EventGenerator, remove it from here. is Connection’s method currently setPaintStyle ? wire that one up to setStyle and deprecate it if so.

Parameters

styleStyle object to set, for example {fillStyle:”blue”}.

@deprecated use setPaintStyle instead.

paint

this.paint = function(params)

Paints the Endpoint, recalculating offset and anchor positions if necessary.

Parameters

timestampoptional timestamp advising the Endpoint of the current paint time; if it has painted already once for this timestamp, it will not paint again.
canvasoptional Canvas to paint on.  Only used internally by jsPlumb in certain obscure situations.
connectorPaintStylepaint style of the Connector attached to this Endpoint.  Used to get a fillStyle if nothing else was supplied.

Connectors. Straight

The Straight connector draws a simple straight line between the two anchor points.  It does not have any constructor parameters.

Connectors. Flowchart

Provides ‘flowchart’ connectors, consisting of vertical and horizontal line segments.

Functions

Constructor

Parameters

stubminimum length for the stub at each end of the connector. defaults to 30 pixels.

Endpoints.Dot

A round endpoint, with default radius 10 pixels.

Functions

Constructor

Parameters

radiusradius of the endpoint.  defaults to 10 pixels.

Endpoints. Rectangle

A Rectangular Endpoint, with default size 20x20.

Functions

Constructor

Parameters

widthwidth of the endpoint. defaults to 20 pixels.
heightheight of the endpoint. defaults to 20 pixels.

Endpoints. Image

Draws an image as the Endpoint.

Functions

Constructor

Parameters

srclocation of the image to use.

Endpoints. Blank

An Endpoint that paints nothing on the screen, and cannot be interacted with using the mouse.  There are no constructor parameters for this Endpoint.

Endpoints. Triangle

A triangular Endpoint.

Functions

Constructor

Parameters

widthwidth of the triangle’s base.  defaults to 55 pixels.
heightheight of the triangle from base to apex.  defaults to 55 pixels.

Overlays. Arrow

An arrow overlay, defined by four points: the head, the two sides of the tail, and a ‘foldback’ point at some distance along the length of the arrow that lines from each tail point converge into.  The foldback point is defined using a decimal that indicates some fraction of the length of the arrow and has a default value of 0.623.  A foldback point value of 1 would mean that the arrow had a straight line across the tail.

Functions

Constructor

Parameters

lengthdistance in pixels from head to tail baseline. default 20.
widthwidth in pixels of the tail baseline. default 20.
fillStylestyle to use when filling the arrow.  defaults to “black”.
strokeStylestyle to use when stroking the arrow. defaults to null, which means the arrow is not stroked.
lineWidthline width to use when stroking the arrow. defaults to 1, but only used if strokeStyle is not null.
foldbackdistance (as a decimal from 0 to 1 inclusive) along the length of the arrow marking the point the tail points should fold back to.  defaults to 0.623.
locationdistance (as a decimal from 0 to 1 inclusive) marking where the arrow should sit on the connector. defaults to 0.5.
directionindicates the direction the arrow points in. valid values are -1 and 1; 1 is default.

Overlays. PlainArrow

A basic arrow.  This is in fact just one instance of the more generic case in which the tail folds back on itself to some point along the length of the arrow: in this case, that foldback point is the full length of the arrow.  so it just does a ‘call’ to Arrow with foldback set appropriately.

Summary
Functions
ConstructorSee Overlays.Arrow for allowed parameters for this overlay.

Functions

Constructor

See Overlays.Arrow for allowed parameters for this overlay.

Overlays. Diamond

A diamond.  Like PlainArrow, this is a concrete case of the more generic case of the tail points converging on some point...it just happens that in this case, that point is greater than the length of the the arrow.

this could probably do with some help with positioning...due to the way it reuses the Arrow paint code, what Arrow thinks is the center is actually 1/4 of the way along for this guy.  but we don’t have any knowledge of pixels at this point, so we’re kind of stuck when it comes to helping out the Arrow class. possibly we could pass in a ‘transpose’ parameter or something. the value would be -l/4 in this case - move along one quarter of the total length.

Summary
Functions
ConstructorSee Overlays.Arrow for allowed parameters for this overlay.

Functions

Constructor

See Overlays.Arrow for allowed parameters for this overlay.

Overlays. Label

A Label overlay.  For all different renderer types (SVG/Canvas/VML), jsPlumb draws a Label overlay as a styled DIV.  Version 1.3.0 of jsPlumb introduced the ability to set css classes on the label; this is now the preferred way for you to style a label.  The ‘labelStyle’ parameter is still supported in 1.3.0 but its usage is deprecated.  Under the hood, jsPlumb just turns that object into a bunch of CSS directive that it puts on the Label’s ‘style’ attribute, so the end result is the same.

Functions

Constructor

Parameters

cssClassoptional css class string to append to css class.  This string is appended “as-is”, so you can of course have multiple classes defined.  This parameter is preferred to using labelStyle, borderWidth and borderStyle.
labelthe label to paint.  May be a string or a function that returns a string.  Nothing will be painted if your label is null or your label function returns null.  empty strings will be painted.
locationdistance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5.
labelStyle(deprecated) js object containing style instructions for the label. defaults to jsPlumb.Defaults.LabelStyle.
borderWidth(deprecated) width of a border to paint.  defaults to zero.
borderStyle(deprecated) strokeStyle to use when painting the border, if necessary.
this.addEndpoint = function(el,
params,
referenceParams)
Adds an Endpoint to a given element or elements.
Models an endpoint.
this.addEndpoints = function(el,
endpoints,
referenceParams)
Adds a list of Endpoints to a given element or elements.
this.animate = function(el,
properties,
options)
This is a wrapper around the supporting library’s animate function; it injects a call to jsPlumb in the ‘step’ function (creating the ‘step’ function if necessary).
this.connect = function(params,
referenceParams)
Establishes a Connection between two elements (or Endpoints, which are themselves registered to elements).
The connecting line between two Endpoints.
this.deleteEndpoint = function(object)
Deletes an Endpoint and removes all Connections it has (which removes the Connections from the other Endpoints involved too)
this.deleteEveryEndpoint = function()
Deletes every Endpoint, and their associated Connections, in this instance of jsPlumb.
this.detach = function(source,
target)
Detaches and then removes a Connection.
this.detachAllConnections = function(el)
Removes all an element’s Connections.
this.detachEveryConnection = function()
Remove all Connections from all elements, but leaves Endpoints in place.
this.draggable = function(el,
options)
Initialises the draggability of some element or elements.
this.extend = function(o1,
o2)
Wraps the underlying library’s extend functionality.
this.getDefaultEndpointType = function()
Returns the default Endpoint type.
this.getDefaultConnectionType = function()
Returns the default Connection type.
this.getConnections = function(options)
Gets all or a subset of connections currently managed by this jsPlumb instance.
this.getAllConnections = function()
Gets all connections, as a map of { scope -> [ connection...
this.getDefaultScope = function()
Gets the default scope for connections and endpoints.
this.hide = function(el,
changeEndpoints)
Sets an element’s connections to be hidden.
this.ready = function(fn)
Helper method to bind a function to jsPlumb’s ready event.
this.repaint = function(el)
Repaints an element and its connections.
this.repaintEverything = function()
Repaints all connections.
this.removeAllEndpoints = function(el)
Removes all Endpoints associated with a given element.
this.setAutomaticRepaint = function(value)
Sets/unsets automatic repaint on window resize.
this.setDefaultScope = function(scope)
Sets the default scope for Connections and Endpoints.
this.setDraggableByDefault = function(draggable)
Sets whether or not elements are draggable by default.
this.setRepaintFunction = function(f)
Sets the function to fire when the window size has changed and a repaint was fired.
this.setMouseEventsEnabled = function(enabled)
Sets whether or not mouse events are enabled.
this.setRenderMode = function(mode)
Sets render mode: jsPlumb.CANVAS, jsPlumb.SVG or jsPlumb.VML.
this.show = function(el,
changeEndpoints)
Sets an element’s connections to be visible.
this.sizeCanvas = function(canvas,
x,
y,
w,
h)
Helper to size a canvas.
this.unload = function()
Unloads jsPlumb, deleting all storage.
var Connection = function(params)
Connection constructor.
this.setConnector = function(connector,
doNotRepaint)
this.addOverlay = function(overlay)
Adds an Overlay to the Connection.
this.getOverlay = function(id)
Gets an overlay, by ID.
this.hideOverlay = function(id)
Hides the overlay specified by the given id.
this.showOverlay = function(id)
Shows the overlay specified by the given id.
this.removeAllOverlays = function()
Removes all overlays from the Connection, and then repaints.
this.setLabel = function(l)
Sets the Connection’s label.
this.repaint = function()
Repaints the Connection.
var Endpoint = function(params)
Endpoint constructor.
this.isVisible = function()
Returns whether or not the Endpoint is currently visible.
this.setVisible = function(v,
doNotChangeConnections,
doNotNotifyOtherEndpoint)
Sets whether or not the Endpoint is currently visible.
this.addConnection = function(connection)
Adds a Connection to this Endpoint.
this.detach = function(connection,
ignoreTarget)
Detaches the given Connection from this Endpoint.
this.detachAll = function()
Detaches all Connections this Endpoint has.
this.detachFrom = function(targetEndpoint)
Removes any connections from this Endpoint that are connected to the given target endpoint.
this.detachFromConnection = function(connection)
Detach this Endpoint from the Connection, but leave the Connection alive.
this.getElement = function()
Returns the DOM element this Endpoint is attached to.
this.getUuid = function()
Returns the UUID for this Endpoint, if there is one.
this.isConnectedTo = function(endpoint)
Returns whether or not this endpoint is connected to the given Endpoint.
this.isFull = function()
Returns whether or not the Endpoint can accept any more Connections.
this.setDragAllowedWhenFull = function(allowed)
Sets whether or not connections can be dragged from this Endpoint once it is full.
this.paint = function(params)
Paints the Endpoint, recalculating offset and anchor positions if necessary.
An arrow overlay, defined by four points: the head, the two sides of the tail, and a ‘foldback’ point at some distance along the length of the arrow that lines from each tail point converge into.
Close