module:ContextMenu(appInstance)

ContextMenu represents the menu that is displayed to the user when they right click on a canvas. This menu allows user to add elements to the canvas and in the case that user rightclicked on a specific element, this menu allows them to remove this element.

new module:ContextMenu(appInstance)

Parameters:
Name Type Description
appInstance App

instance of App this menu belongs to

Members

$el :jQuery.element

jQuery element containing the context menu

appInstance :App

instance of App this menu belongs to

itemCount :Number

Number of items in this menu (used in the .lenght getter). Conditional items do not count.

position :Object

Position of the context menu. It is used to add the new elements to the correct position on the canvas.

Methods

appendConditionalItem(itemClass, text, clickFunction)

appends an connditional item (that is shown only if the target has the class itemClass)

Parameters:
Name Type Description
itemClass string

show the item only if the target has this class

text string

text of this menu item

clickFunction function

function with one argument (ID of the target) that will be called on click

appendItem(item)

append a context menu item to the context menu

Parameters:
Name Type Description
item ContextMenuItem

instance of ContextMenuItem that will be added to this menu

display(x, y, $target)

displays the context menu with the right set of conditional items

Parameters:
Name Type Description
x number

horizontal position of the context menu in CSS pixels

y number

vertical position of the context menu in CSS pixels

$target jQuery.element

jQuery target of a MouseEvent (element that user clicked on)

displayImportDialog()

display the dialog for importing a network from a clipboard

hide()

hide the context menu

hideAllConditionalItems()

hide all conditional items

resolveConditionalItems($target)

decide whether or not to display specific conditional items

Parameters:
Name Type Description
$target jQuery.element

jQuery target of a MouseEvent (element that user clicked on)