Options
All
  • Public
  • Public/Protected
  • All
Menu

A context menu for displaying actions. This class is designed to know how to sort "wed/action".Action objects and "wed/transformation".Transformation objects and how to filter them. Even though the names used here suggest that Action objects are the focus of this class, the fact is that it is really performing its work on Transformation objects. It does accept Action as a kind of lame Transformation. So the following description will focus on Transformation objects rather than Action objects.

Sorting is performed first by the kind of the Transformation and then by the text associated with the Transformation. The kinds, in order, are:

  • other kinds than those listed below

  • undefined kind

  • "add"

  • "delete"

  • "wrap"

  • "unwrap"

The text associated with the transformation is the text value of the DOM Element object stored in the item field of the object given in the items array passed to the constructor. Actions are considered to have an undefined kind.

Filtering is performed by kind and on the text of the element name associated with a transformation. This class presents to the user a row of buttons that represent graphically the possible filters. Clicking on a button will reduce the list of displayed items only to those elements that correspond to the kind to which the button corresponds.

Typing text (e.g. "foo") will narrow the list of items to the text that the user typed. Let's suppose that item is successively taking the values in the items array. The filtering algorithm first checks whether there is an item.data.name field. If there is, the match is performed against this field. If not, the match is performed against the text of item.item.

If the text typed begins with a caret (^), the text will be interpreted as a regular expression.

Typing ESCAPE will reset filtering.

When no option is focused, typing ENTER will select the first option of the menu.

Hierarchy

Index

Constructors

constructor

  • Parameters

    • document: Document

      The DOM document for which to make this context menu.

    • x: number

      Position of the menu. The context menu may ignore this position if the menu would appear off-screen.

    • y: number

      Position of the menu.

    • items: Item[]

      An array of action information in the form of anonymous objects. It is valid to have some items in the array be of the form {action: null, item: some_element, data: null} to insert arbitrary menu items.

    • Optional dismissCallback: DismissCallback

      Function to call when the menu is dismissed.

    Returns ActionContextMenu

Properties

Protected $menu

$menu: JQuery

The jQuery equivalent of menu.

Protected $toggle

$toggle: JQuery

The jQuery equivalent of toggle.

Private actionFilterInput

actionFilterInput: HTMLInputElement

Private actionFilterItem

actionFilterItem: Element

Private actionItems

actionItems: Item[]

Private actionTextFilter

actionTextFilter: string = ""

Protected backdrop

backdrop: Element

Protected dismissed

dismissed: boolean

Protected dropdown

dropdown: HTMLElement

Protected menu

menu: HTMLElement

The Element that contains the list of menu items. This Element is an HTML list. It is created at construction of the object and deleted only when the object is destroyed. This is what the ContextMenu.render method should populate.

Protected toggle

toggle: HTMLElement

The toggle element of the dropdown menu. Even though it is not shown for our menus, it is necessary, and plays a role in how the menu works.

Methods

Private actionKeydownHandler

  • actionKeydownHandler(ev: JQueryKeyEventObject): boolean

Private actionKeypressHandler

  • actionKeypressHandler(ev: JQueryKeyEventObject): boolean

Private computeActionItemsToDisplay

  • computeActionItemsToDisplay(items: Item[]): Element[]

dismiss

  • dismiss(): void

Protected display

  • display(items: Element[]): void

handleToggleFocus

  • handleToggleFocus(): void

Private inputChangeHandler

  • inputChangeHandler(ev: KeyboardEvent): void

Private inputKeydownHandler

  • inputKeydownHandler(ev: KeyboardEvent): boolean

Private makeKindGroup

  • makeKindGroup(document: Document): Element

Private makeKindHandler

  • makeKindHandler(kind: string | undefined): function

Private makeTypeGroup

  • makeTypeGroup(document: Document): Element

Private makeTypeHandler

  • makeTypeHandler(actionType: string | undefined): function

render

  • render(): void

Object literals

Private filters

filters: object

kind

kind: null = null

type

type: null = null

Generated using TypeDoc