Options
All
  • Public
  • Public/Protected
  • All
Menu

Display a right-click activated Context Menu which provides a dropdown menu of options A ContextMenu is constructed by designating a parent HTML container and a target selector An Array of menuItems defines the entries of the menu which is displayed

Hierarchy

  • ContextMenu

Index

Constructors

Properties

element: HTMLElement

The target HTMLElement being selected

selector: string

The target CSS selector which activates the menu

eventName: string

An interaction event name which activates the menu

menuItems: ContextMenuEntry[]

The array of menu items being rendered

onOpen: Function

A function to call when the context menu is opened.

onClose: Function

A function to call when the context menu is closed.

_expandUp: boolean

Track which direction the menu is expanded in

#target: HTMLElement

The parent HTML element to which the context menu is attached

Accessors

  • get menu(): any
  • A convenience accessor to the context menu HTML object

    Returns any

Methods

  • bind(): void
  • Attach a ContextMenu instance to an HTML selector

    Returns void

  • close([options]?: { animate: boolean }): Promise<void>
  • Closes the menu and removes it from the DOM.

    Parameters

    • [options]: { animate: boolean } = {}

      Options to configure the closing behavior.

      • animate: boolean

    Returns Promise<void>

  • _close(): void
  • Returns void

  • _animateOpen(menu: any): Promise<any>
  • Parameters

    • menu: any

    Returns Promise<any>

  • _animateClose(menu: any): Promise<any>
  • Parameters

    • menu: any

    Returns Promise<any>

  • render(target: jQuery): Promise<any>
  • Render the Context Menu by iterating over the menuItems it contains. Check the visibility of each menu item, and only render ones which are allowed by the item's logical condition. Attach a click handler to each item which is rendered.

    Parameters

    • target: jQuery

      The target element to which the context menu is attached

    Returns Promise<any>

  • activateListeners(html: jQuery): void
  • Local listeners which apply to each ContextMenu instance which is created.

    Parameters

    • html: jQuery

    Returns void

  • _setPosition(html: any, target: any): void
  • Set the position of the context menu, taking into consideration whether the menu should expand upward or downward

    Parameters

    • html: any
    • target: any

    Returns void

  • #onClickItem(event: PointerEvent): void
  • Handle click events on context menu items.

    Parameters

    • event: PointerEvent

      The click event

    Returns void

  • Create a ContextMenu for this Application and dispatch hooks.

    Parameters

    • app: Application

      The Application this ContextMenu belongs to.

    • html: jQuery

      The Application's rendered HTML.

    • selector: string

      The target CSS selector which activates the menu.

    • menuItems: ContextMenuEntry[]

      The array of menu items being rendered.

    • [options]: { hookName: string } = {}

      Additional options to configure context menu initialization.

      • hookName: string

    Returns ContextMenu

  • eventListeners(): void
  • Global listeners which apply once only to the document.

    Returns void