Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Reorder

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected childrenInOriginalOrder

childrenInOriginalOrder: Map<HTMLElement, JQuery>

Map from HTML parent elements to JQuery children nodes, in their original order. This is used to save the original element ordering.

Abstract name

name: string

Private nonReorderableElementsInitialIndices

nonReorderableElementsInitialIndices: Map<HTMLElement, number>

Map from HTML elements to their original indices. This is used to move non-reorderable elements back to their original position.

Static NON_REORDERABLE_ELEMENT_CLASS

NON_REORDERABLE_ELEMENT_CLASS: "sam-no-reordering" = "sam-no-reordering"

HTML class of items or groups whose nodes must not be reordered.

Such elements are flagged accordingly when they are created (see Item.canBeReordered and ItemGroup.canBeReordered).

Methods

Abstract apply

cancel

  • cancel(): void

Protected getReorderedElementClass

  • getReorderedElementClass(): string
  • Return the HTML class to add to elements which have been reordered.

    This method should be overriden by any child class willing to distinguish the elements it can reorder by their class.

    Returns string

    The class to add to reordered elements.

Protected Abstract getReorderedElementType

  • getReorderedElementType(): string

Private getSortedChildrenIndices

  • getSortedChildrenIndices(parent: JQuery): number[]
  • Sort and return the indices of all the child nodes of the given parent node which can be reordered, i.e. which have a matching adaptive element type (according to Reorder.getReorderedElementType).

    Parameters

    • parent: JQuery

      The parent node containing reorderable child nodes whose indices must be sorted.

    Returns number[]

    A sorted list of child node indices.

Private insertNode

  • insertNode(node: JQuery, index: number): void
  • Reinsert the given node at the given index (in its own parent).

    Parameters

    • node: JQuery

      The node to reinsert.

    • index: number

      The new index of the node.

    Returns void

Private moveReorderableNode

  • moveReorderableNode(node: JQuery, index: number): void
  • Move the given node at the given index (in its own parent), and add a class to the node to mark it as reordered.

    Parameters

    • node: JQuery

      The node to move.

    • index: number

      The new index of the node.

    Returns void

Private reinsertNonReorderableElements

  • reinsertNonReorderableElements(): void

Protected reorderAllElements

  • Reorder all given elements in the given order.

    Non-given elements may be moved to a higher index if need be, except for elements marked as non-reorderable.

    This method expects a complete list of menu adaptive elements, supposedly computed by a policy. It was designed to be called by implementations of AdaptationStyle.apply.

    Parameters

    Returns void

Private saveNonReorderableElementsOriginalIndices

  • saveNonReorderableElementsOriginalIndices(parent: JQuery): void

Protected saveParentNodeChildrenInOriginalOrder

  • Save the original order of all children of all the nodes of the given adaptive elements.

    The order is saved by saving an array of references to all the children(as jQuery nodes) in their original orders.

    Parameters

    • elements: AdaptiveElement[]

      The adaptive elements whose children order must be saved.

    Returns void

Private splitNodesByParents

  • splitNodesByParents(nodes: JQuery[]): Map<HTMLElement, JQuery[]>
  • Compute and return a map from each unique parent element (of all given nodes) to an array of all their children.

    The original order of the children is conserved in the arrays.

    Parameters

    • nodes: JQuery[]

      The nodes to split by their parents.

    Returns Map<HTMLElement, JQuery[]>

    A map from parent elements to arrays of child nodes.

Generated using TypeDoc