Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

groups

groups: ItemGroup[]

List of all the menu groups.

id

id: string

Unique ID of the element. It should be computed once, before any adaptation, using getID method.

node

node: JQuery

Node of the element.

parent

parent: null

null since a menu always has no parent.

selector

selector: Selector | NoSelector

Selector used to find the node. If no selector was used, it should be set to NO_SELECTOR.

Static ELEMENT_TYPE

ELEMENT_TYPE: string = "menu"

Type of menu element.

Static HTML_CLASS

HTML_CLASS: string = "sam-menu"

Standard HTML class for menu elements.

Static TAG_PREFIX

TAG_PREFIX: string = "data-sam-"

Prefix of all tags added to nodes by SAM. It acts as a sort of HTML attribute namespace.

Methods

Private fillUsingGenericGroupAndItemSelectors

  • fillUsingGenericGroupAndItemSelectors(groupSelector: Selector, itemSelector: Selector): void
  • Fill the menu with groups and items according to the specification of the variant of fromSelectors with three arguments.

    This method is meant for internal use only (see fromSelectors).

    Parameters

    • groupSelector: Selector

      Selector of the group nodes.

    • itemSelector: Selector

      Selector of the item nodes.

    Returns void

Private fillUsingGenericItemSelector

  • fillUsingGenericItemSelector(itemSelector: Selector): void
  • Fill the menu with a single group and items according to the specification of the variant of fromSelectors with two arguments.

    This method is meant for internal use only (see fromSelectors).

    Parameters

    • itemSelector: Selector

      Selector of the item nodes.

    Returns void

Private fillUsingSpecificGroupSelectors

  • fillUsingSpecificGroupSelectors(descendantSelectors: object): void
  • Fill the menu with groups and items according to the specification of the variant of fromSelectors with one argument.

    This method is meant for internal use only (see fromSelectors).

    Parameters

    • descendantSelectors: object

      Object of item selectors indexed by their parent group selectors.

    Returns void

getAllItemNodes

  • getAllItemNodes(): JQuery[]
  • Return a list of all the menu item nodes.

    Returns JQuery[]

    A list of all item nodes.

getAllItems

  • getAllItems(): Item[]

getSelector

  • getSelector(): string

getTag

  • getTag(name: string): string | undefined

getType

  • getType(): string

tag

  • tag(name: string, value: string): void
  • Add a tag to the element node, i.e. an prefixed HTML attribute. Note: the prefix is automatically prepended to the tag name.

    Parameters

    • name: string

      The name of the tag (without the prefix).

    • value: string

      The value of the attribute.

    Returns void

Static fromSelectors

  • Create a menu from the given menu and item selectors. It will only have one group, whose node will be the same as the menu node.

    Item nodes are only searched inside the menu node.

    Parameters

    • menuSelector: Selector

      Selector of the menu node.

    • itemSelector: Selector

      Selector of the item nodes.

    Returns Menu

    A new instance of Menu.

  • Create a menu from the given menu, group and item selectors.

    The menu node must not be a group node itself (see the variant of fromSelectors with two arguments instead).

    Group nodes are only searched inside the menu node. Item nodes are only searched inside the group node.

    Parameters

    • menuSelector: Selector

      Selector of the menu node.

    • groupSelector: Selector

      Selector of the group nodes.

    • itemSelector: Selector

      Selector of the item nodes.

    Returns Menu

    A new instance of Menu.

  • Create a menu manager from the given specific selectors. Each key of descendantSelectors must be a group selector, and each related value must be the selector of the group items.

    The menu node must not be a group node itself (see the variant of fromSelectors with two arguments instead).

    Group nodes are only searched inside the menu node. Item nodes are only searched inside the group node.

    Parameters

    • menuSelector: Selector

      Selector of the menu node.

    • descendantSelectors: object

      Object of item selectors indexed by their parent group selectors.

    Returns Menu

    A new instance of Menu.

Static getAllMenusGroups

  • Get all the groups of the given menus.

    Parameters

    • menus: Menu[]

      A list of menus containing the groups to return.

    Returns ItemGroup[]

    A list of all the groups.

Static getAllMenusItems

  • getAllMenusItems(menus: Menu[]): Item[]
  • Get all the items of the given menus.

    Parameters

    • menus: Menu[]

      A list of menus containing the items to return.

    Returns Item[]

    A list of all the items.

Static getNodeTag

  • getNodeTag(node: JQuery, name: string): string | undefined
  • Get the value of a tag of the given node. Note: the prefix is automatically prepended to the tag name.

    Parameters

    • node: JQuery

      The tagged node (with the attribute).

    • name: string

      The name of the tag (without the prefix).

    Returns string | undefined

    The value of the tag, or undefined if the tag was not found.

Static nodeToSelector

  • nodeToSelector(node: JQuery): string
  • Return a standalone jQuery string selector for the given node, i.e. $(<selector>) should select the node.

    The selector is built recursively, in the following way:

    • if the node is the body or html node, it returns the related tag selector;
    • if the node has an ID, it returns the related ID selector;
    • otherwise, it calls nodeToSelector on the parent node of the given node, and returns the result with the following concatenation: (1) a child selector (>); (2) the node tag; (3) the node positional selector (:eq(<index>)).

    Parameters

    • node: JQuery

      The node to represent with a selector.

    Returns string

    The standalone selector.

Generated using TypeDoc