Class OpenableAbstract

Openable is an abstract base class. You should not directly instantiate it but can inherit it to create your own custom openable widget.

IMPORTANT: You should not instantiate more than one Openable widget, regardless of type, on a given element. Use Openable.get to get an existing instance if any. If there is already an Openable widget of any type on this element, it will be destroyed!

Hierarchy (View Summary)

Methods

  • Retrieve an existing widget by its content element or any of its triggers.

    If the element is already part of a configured Openable widget, the widget instance is returned. Otherwise null.

    Note that trigger elements are not guaranteed to be unique among openable widgets as the same element can be a trigger for multiple such widgets. If the element you pass is a trigger, then the last openable widget that was created for it will be returned.

    Parameters

    • element: Element

    Returns null | Openable

Constructors

Properties

close: () => Promise<void>

Closes the widget.

destroy: () => Promise<void>

Undoes all modifications to the element and returns it to its original state.

You will need to recreate it if you want to enable its functionality again.

disable: () => Promise<void>

Disables the functionality of the widget. What this means is specific to each widget.

enable: () => Promise<void>

Re-enables the functionality of the widget. What this means is specific to each widget.

getContainer: () => null | HTMLElement

Returns the element that was found to be the container. It is the closest ancestor that has a lisn-collapsible-container class, or if no such ancestor then the immediate parent of the content element.

getElement: () => Element

Returns the element passed to the widget constructor.

getRoot: () => HTMLElement

Returns the root element created by us that wraps the original content element passed to the constructor. It is located in the content element's original place.

getTriggerConfigs: () => Map<Element, OpenableTriggerConfig>

Returns the trigger elements along with their configuration.

getTriggers: () => Element[]

Returns the trigger elements, if any. Note that these may be wrappers around the original triggers passed.

isDestroyed: () => boolean

Returns true if the widget is destroyed.

isDisabled: () => boolean

Returns true if the widget is currently disabled.

isOpen: () => boolean

Returns true if the widget is currently open.

onClose: (handler: WidgetHandler) => void

The given handler will be called when the widget is closed.

If it returns a promise, it will be awaited upon.

onDestroy: (handler: WidgetHandler) => void

The given handler will be called when the widget is destroyed.

onDisable: (handler: WidgetHandler) => void

The given handler will be called when the widget is disabled.

onEnable: (handler: WidgetHandler) => void

The given handler will be called when the widget is enabled.

onOpen: (handler: WidgetHandler) => void

The given handler will be called when the widget is open.

If it returns a promise, it will be awaited upon.

open: () => Promise<void>

Opens the widget unless it is disabled.

toggle: () => Promise<void>

Closes the widget if it is open, or opens it if it is closed (unless it is disabled).

toggleEnable: () => Promise<void>

Re-enables the widget if disabled, otherwise disables it.