ServiceModule Class
Manage service rendering and events.
Emitted events:
- clearState: clear all possible states that the environment view can be in as it pertains to actions (building a relation, viewing a service menu, etc.)
- snapToService: fired when mousing over a service, causing the pending relation dragline to snap to the service rather than following the mouse.
- snapOutOfService: fired when mousing out of a service, causing the pending relation line to follow the mouse again.
- addRelationDrag:
- addRelationDragStart:
- addRelationDragEnd: fired when creating a relation through the long- click process, when moving the cursor over the environment, and when dropping the endpoint on a valid service.
- cancelRelationBuild: fired when dropping a pending relation line started through the long-click method somewhere other than a valid service.
- serviceMoved: fired when a service block is dragged so that relation endpoints can follow it.
- navigateTo: fired when clicking the "View Service" menu item or when double-clicking a service.
Item Index
Methods
- _touchstartServiceClick
- attachTouchstartEvents
- backgroundClicked
- canvasClick
- clearStateHandler
- createServiceNode
- destroyServiceClick
- drag
- dragstart
- getServiceNode
- hideServiceMenu
- serviceClick
- serviceMouseMove
- serviceStatusMouseOver
- showServiceMenu
- toggleServiceMenu
- updateServiceNodes
- viewServiceClick
Methods
_touchstartServiceClick
-
e -
topo
Callback for the touchstart event handlers on the service svg elements
Parameters:
-
eObjectevent object from tap.
-
topoObjecttopography instance reference.
attachTouchstartEvents
-
data -
node
Attaches the touchstart event handlers for the service elements. This is required because touchstart does not appear to bubble in Chrome for Android 4.2.2.
Parameters:
-
dataObjectD3 data object.
-
nodeDOM ElementSVG DOM element.
backgroundClicked
()
Undefined
The user clicked on the environment view background.
If we are in the middle of adding a relation, cancel the relation adding.
Returns:
canvasClick
()
If the user clicks on the background we cancel any active add relation.
clearStateHandler
()
Undefined
Clear any stateful actions (menus, etc.) when a clearState event is received.
Returns:
createServiceNode
-
node -
self
Fill a service node with empty structures that will be filled out in the update stage.
Parameters:
-
nodeObjectthe node to construct.
-
selfObjectreference to the view instance.
Returns:
destroyServiceClick
()
The user clicked on the "Destroy" menu item.
drag
-
d -
self -
pos -
includeTransition
Specialized drag event handler when called as an event handler it Allows optional extra param, pos which when used overrides the mouse handling. This method can then be though of as 'drag to position'.
Parameters:
-
dBoxviewModel BoundingBox.
-
selfServiceModuleServiceModule.
-
posObject(optional) containing x/y numbers.
-
includeTransitionBoolean(optional) Use transition to drag.
[At the time of this writing useTransition works in practice but introduces a timing issue in the tests.]
dragstart
-
box -
self
Handle drag events for a service.
Parameters:
-
boxBoxA bounding box.
-
selfModuleService Module.
Returns:
getServiceNode
()
d3.selection
Get a d3 selected node for a given service by id.
Returns:
hideServiceMenu
-
box
Hide the service menu.
Parameters:
-
boxObjectThe presentation state for the service (unused).
Returns:
serviceClick
-
box -
self -
eType
Handles the click or tap on the service svg elements.
It is executed under the context of the clicked/tapped DOM element
Parameters:
-
boxObjectservice object model instance.
-
selfObjectthis service module instance.
-
eTypeStringstring representing if it's 'touch' or not.
serviceMouseMove
-
d -
context
Handle a mouse moving over a service.
Parameters:
-
dObjectUnused.
-
contextObjectUnused.
Returns:
serviceStatusMouseOver
()
Handle mouseover service status
showServiceMenu
-
box
Show the service menu.
Parameters:
-
boxObjectThe presentation state for the service.
Returns:
toggleServiceMenu
-
box
Show (if hidden) or hide (if shown) the service menu.
Parameters:
-
boxObjectThe presentation state for the service.
Returns:
updateServiceNodes
-
node
Fill the empty structures within a service node such that they match the db.
Parameters:
-
nodeObjectthe collection of nodes to update.
Returns:
viewServiceClick
()
The user clicked on the "View" menu item.
Events
clearState
Clear view state as pertaining to services.
drag
Event fired while a service is being dragged or dragline being moved.
Event Payload:
-
boxObjectThe service box that's being dragged.
-
selfObjectThis class.
dragend
Event fired after a service is being dragged or dragline being moved.
Event Payload:
-
boxObjectThe service box that's being dragged.
-
selfObjectThis class.
dragstart
Start the service drag process or the add-relation dragline process.
Event Payload:
-
boxObjectThe service box that's being dragged.
-
selfObjectThis class.
fade
Fade a given service (set opacity to 0.2).
Event Payload:
-
AnObjectobject with a d3 selection attribute.
hide
Hide a given service (set opacity to 0).
Event Payload:
-
AnObjectobject with a d3 selection attribute.
hideServiceMenu
Hide a service's click-actions menu.
rescaled
Update the service menu location.
show
Show a hidden service (set opacity to 1.0).
Event Payload:
-
AnObjectobject with a d3 selection attribute.
