Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

canBeReordered

canBeReordered: boolean

Flag indicating whether the item can be reordered or not.

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: ItemGroup

Group element owning the item.

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 = "item"

Type of item elements.

Static HTML_CLASS

HTML_CLASS: string = "sam-item"

Standard HTML class for item 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

findLinkNodes

  • findLinkNodes(pageID?: PageID): JQuery

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 fromSelector

  • Create an item from the given selector.

    Parameters

    • selector: Selector

      Selector of the item node.

    • parent: ItemGroup

      The group containing this item.

    Returns Item

    A new instance of Item.

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.

Static splitAllByGroup

  • splitAllByGroup(items: Item[]): Item[][]
  • Split the given list of items into sub-lists of items of the same group. The order of the initial list is respected in each sub-list.

    Parameters

    • items: Item[]

      The items to split by group.

    Returns Item[][]

    A list of lists of split items.

Generated using TypeDoc