## 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)
`modules/ui/ContextMenu.js`, `line 245`

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `appInstance` | App | instance of App this menu belongs to

### Members

#### $el :jQuery.element
`modules/ui/ContextMenu.js`, `line 269`

  jQuery element containing the context menu

#### appInstance :App
`modules/ui/ContextMenu.js`, `line 254`

  instance of App this menu belongs to

#### itemCount :Number
`modules/ui/ContextMenu.js`, `line 365`

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

#### position :Object
`modules/ui/ContextMenu.js`, `line 260`

  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)
`modules/ui/ContextMenu.js`, `line 390`

  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)
`modules/ui/ContextMenu.js`, `line 376`

  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)
`modules/ui/ContextMenu.js`, `line 496`

  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()
`modules/ui/ContextMenu.js`, `line 405`

  display the dialog for importing a network from a clipboard

#### hide()
`modules/ui/ContextMenu.js`, `line 519`

  hide the context menu

#### hideAllConditionalItems()
`modules/ui/ContextMenu.js`, `line 486`

  hide all conditional items

#### resolveConditionalItems($target)
`modules/ui/ContextMenu.js`, `line 471`

  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)