StaticgetRetrieve 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.
StaticregisterOptionalconfig: CollapsibleConfigReadonlycloseCloses the widget.
ReadonlydestroyUndoes 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.
ReadonlydisableDisables the functionality of the widget. What this means is specific to each widget.
ReadonlyenableRe-enables the functionality of the widget. What this means is specific to each widget.
ReadonlygetReturns 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.
ReadonlygetReturns the element passed to the widget constructor.
ReadonlygetReturns 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.
ReadonlygetReturns the trigger elements along with their configuration.
ReadonlygetReturns the trigger elements, if any. Note that these may be wrappers around the original triggers passed.
ReadonlyisReturns true if the widget is destroyed.
ReadonlyisReturns true if the widget is currently disabled.
ReadonlyisReturns true if the widget is currently open.
ReadonlyonThe given handler will be called when the widget is closed.
If it returns a promise, it will be awaited upon.
ReadonlyonThe given handler will be called when the widget is destroyed.
ReadonlyonThe given handler will be called when the widget is disabled.
ReadonlyonThe given handler will be called when the widget is enabled.
ReadonlyonThe given handler will be called when the widget is open.
If it returns a promise, it will be awaited upon.
ReadonlyopenOpens the widget unless it is disabled.
ReadonlytoggleCloses the widget if it is open, or opens it if it is closed (unless it is disabled).
ReadonlytoggleRe-enables the widget if disabled, otherwise disables it.
Configures the given element as a Collapsible widget.
The Collapsible widget sets up the given element to be collapsed and expanded upon activation. Activation can be done manually by calling open or when clicking on any of the given triggers.
NOTE: The Collapsible widget always wraps each trigger element in another element in order to allow positioning the icon, if any.
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!
You can use the following dynamic attributes or CSS properties in your stylesheet:
The following dynamic attributes are set on the root element that is created by LISN and has a class
lisn-collapsible__root:data-lisn-is-open:"true"or"false"data-lisn-reverse:"true"or"false"data-lisn-orientation:"horizontal"or"vertical"The following dynamic attributes are set on each trigger:
data-lisn-opens-on-hover:"true"or"false"`To use with auto-widgets (HTML API) (see settings.autoWidgets), the following CSS classes or data attributes are recognized:
lisn-collapsibleclass ordata-lisn-collapsibleattribute set on the element that holds the content of the collapsiblelisn-collapsible-triggerclass ordata-lisn-collapsible-triggerattribute set on elements that should act as the triggers. If using a data attribute, you can configure the trigger via the value with a similar syntax to the configuration of the openable widget. For example:"hover"in order to have this trigger open the collapsible on hover in addition to click."hover|auto-close"in order to have this trigger open the collapsible on hover but and override CollapsibleConfig.autoClose with true.When using auto-widgets, the elements that will be used as triggers are discovered in the following way:
data-lisn-collapsible-content-idattribute, then it must be a unique (for the current page) ID. In this case, the trigger elements will be any element in the document that has alisn-collapsible-triggerclass ordata-lisn-collapsible-triggerattribute and the samedata-lisn-collapsible-content-idattribute.lisn-collapsible-containerclass, or if no such ancestor then the immediate parent of the content element, is searched for any elements that have alisn-collapsible-triggerclass ordata-lisn-collapsible-triggerattribute and that do not have adata-lisn-collapsible-content-idattribute, and that are not children of the content element.See below examples for what values you can use set for the data attributes in order to modify the configuration of the automatically created widget.
Example
This defines a simple collapsible with one trigger.
Example
This defines a collapsible that is partially visible when collapsed, and where the trigger is in a different parent to the content.
Example
As above, but with all other possible configuration settings set explicitly.