Constructor
new Popup(attrs, …childopt) → {Widget}
Creates a new popup widget.
- Parameters:
-
Name Type Attributes Description attrs
{Object} the widget and node attributes Properties
Name Type Attributes Description delay
{number} <optional>
the widget auto-hide delay in milliseconds, defaults to 5000
hidden
{boolean} <optional>
the hidden widget flag, defaults to true
child
{Node|Array} <optional>
<repeatable>
the child widgets or DOM nodes - Returns:
- {Widget} the widget DOM node
- Examples:
-
JavaScript
let hr = document.createElement("hr"); let third = RapidContext.UI.LI({ "class": "disabled" }, "Third"); let popup = RapidContext.Widget.Popup({}, "First", "Second", hr, third);
User Interface XML
<Popup id="examplePopup"> <li>» First Item</div> <li>» Second Item</div> <hr /> <li class="disabled">» Third Item</div> </Popup>
- Source:
- RapidContext_Widget_Popup.js, line 52
Extends
Methods
addAll(…child)
Adds one or more children to this widget. This method will flatten any
arrays among the arguments and ignores any null
or undefined
arguments.
Any DOM nodes or widgets will be added to the end, and other objects will be
converted to a text node first. Subclasses should normally override the
addChildNode()
method instead of this one, since that is the basis for
DOM node insertion.
- Parameters:
-
Name Type Attributes Description child
{string|Node|Array} <repeatable>
the children to add - Inherited From:
- RapidContext.Widget#addAll
- Source:
- RapidContext_Widget.js, line 535
addChildNode(child)
Adds a single child node to this widget.
- Parameters:
-
Name Type Description child
{string|Node|Widget} the item to add - Overrides:
- RapidContext.Widget#addChildNode
- Source:
- RapidContext_Widget_Popup.js, line 125
addClass(…cls)
Adds the specified CSS class names to this HTML DOM node.
- Parameters:
-
Name Type Attributes Description cls
{string|Array} <repeatable>
the CSS class names to add - Inherited From:
- RapidContext.Widget#addClass
- Source:
- RapidContext_Widget.js, line 329
blurAll()
Blurs (unfocuses) this DOM node and all relevant child nodes. This function
will recursively blur all <a>
, <button>
, <input>
, <textarea>
and
<select>
child nodes found.
- Inherited From:
- RapidContext.Widget#blurAll
- Source:
- RapidContext_Widget.js, line 475
destroy()
The internal widget destructor function. This method should only
be called by destroyWidget()
and may be overridden by subclasses.
By default this method does nothing.
- Inherited From:
- RapidContext.Widget#destroy
- Source:
- RapidContext_Widget.js, line 198
disable()
Disables this widget if it was previously enabled. This method is
equivalent to calling setAttrs({ disabled: true })
.
- Inherited From:
- RapidContext.Widget#disable
- Source:
- RapidContext_Widget.js, line 420
emit(event, optsopt) → {boolean}
Dispatches a single event from this DOM node. Also creates a new CustomEvent instance if needed.
- Parameters:
-
Name Type Attributes Description event
{string/Event} the event type name or instance opts
{Object} <optional>
the event options Properties
Name Type Attributes Default Description async
{boolean} <optional>
true the async dispatch flag bubbles
{boolean} <optional>
the event bubbles flag cancelable
{boolean} <optional>
the cancellable event flag detail
{Object} <optional>
the additional event details - Returns:
-
{boolean}
true
if event was async or not cancelled - Inherited From:
- RapidContext.UI.Event#emit
- Source:
- rapidcontext/ui/event.mjs, line 26
enable()
Enables this widget if it was previously disabled. This is
equivalent to calling setAttrs({ disabled: false })
.
- Inherited From:
- RapidContext.Widget#enable
- Source:
- RapidContext_Widget.js, line 412
getChildNodes() → {Array}
Returns an array with all child DOM nodes. Note that the array is
a real JavaScript array, not a dynamic NodeList
. This method is
sometimes overridden by child widgets in order to hide
intermediate DOM nodes required by the widget.
- Returns:
- {Array} the array of child DOM nodes
- Inherited From:
- RapidContext.Widget#getChildNodes
- Source:
- RapidContext_Widget.js, line 487
hasClass(…cls) → {boolean}
Checks if this HTML DOM node has the specified CSS class names. Note that more than one CSS class name may be checked, in which case all must be present.
- Parameters:
-
Name Type Attributes Description cls
{string|Array} <repeatable>
the CSS class names to check - Returns:
-
{boolean}
true
if all CSS classes were present, orfalse
otherwise - Inherited From:
- RapidContext.Widget#hasClass
- Source:
- RapidContext_Widget.js, line 311
hide()
Hides this widget node if it was previously visible. This method
is equivalent to calling setAttrs({ hidden: true })
. It is safe
for all types of widgets, since it only adds the widgetHidden
CSS class instead of setting the display
style property.
- Inherited From:
- RapidContext.Widget#hide
- Source:
- RapidContext_Widget.js, line 466
isDisabled() → {boolean}
Checks if this widget is disabled. This method checks both the
"widgetDisabled" CSS class and the disabled
property. Changes
to the disabled status can be made with enable()
, disable()
or
setAttrs()
.
- Returns:
-
{boolean}
true
if the widget is disabled, orfalse
otherwise - Inherited From:
- RapidContext.Widget#isDisabled
- Source:
- RapidContext_Widget.js, line 391
isHidden() → {boolean}
Checks if this widget node is hidden. This method checks for the
existence of the widgetHidden
CSS class. It does NOT check the
actual widget visibility (the display
style property set by
animations for example).
- Returns:
-
{boolean}
true
if the widget is hidden, orfalse
otherwise - Inherited From:
- RapidContext.Widget#isHidden
- Source:
- RapidContext_Widget.js, line 433
off(eventopt, selectoropt, listeneropt) → {Node}
Removes one or more previously attached event listeners. If no event details or listeners are specified, all matching handlers are removed.
- Parameters:
-
Name Type Attributes Description event
{string} <optional>
the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} <optional>
the event handler function (or false
) - Returns:
- {Node} the input DOM node (for chaining calls)
- Inherited From:
- RapidContext.UI.Event#off
- Source:
- rapidcontext/ui/event.mjs, line 77
on(event, selectoropt, listener, optsopt) → {Node}
Attaches a listener function for one or more events.
- Parameters:
-
Name Type Attributes Description event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Inherited From:
- RapidContext.UI.Event#on
- Source:
- rapidcontext/ui/event.mjs, line 44
once(event, selectoropt, listener, optsopt) → {Node}
Attaches a single event listener function. The listener will be removed the first time an event is triggered.
- Parameters:
-
Name Type Attributes Description event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Inherited From:
- RapidContext.UI.Event#once
- Source:
- rapidcontext/ui/event.mjs, line 60
removeAll()
Removes all children to this widget. This method will also destroy and child
widgets and disconnect all signal listeners. This method uses the
getChildNodes()
and removeChildNode()
methods to find and remove the
individual child nodes.
- Inherited From:
- RapidContext.Widget#removeAll
- Source:
- RapidContext_Widget.js, line 547
removeChildNode(child)
Removes a single child DOM node from this widget. This method is sometimes overridden by child widgets in order to hide or control intermediate DOM nodes required by the widget.
Note that this method will NOT destroy the removed child widget, so care must be taken to ensure proper child widget destruction.
- Parameters:
-
Name Type Description child
{Widget|Node} the DOM node to remove - Inherited From:
- RapidContext.Widget#removeChildNode
- Source:
- RapidContext_Widget.js, line 518
removeClass(…cls)
Removes the specified CSS class names from this HTML DOM node. Note that this method will not remove any class starting with "widget".
- Parameters:
-
Name Type Attributes Description cls
{string|Array} <repeatable>
the CSS class names to remove - Inherited From:
- RapidContext.Widget#removeClass
- Source:
- RapidContext_Widget.js, line 349
resetDelay()
Resets the popup auto-hide timer. Might be called manually when receiving events on other widgets related to this one.
- Source:
- RapidContext_Widget_Popup.js, line 159
selectChild(indexOrNode)
Marks a popup child as selected. The currently selected child will automatically be unselected by this method.
- Parameters:
-
Name Type Description indexOrNode
{number|Node} the child node index or DOM node, use a negative value to unselect - Returns:
- the index of the newly selected child, or -1 if none was selected
- Source:
- RapidContext_Widget_Popup.js, line 189
selectMove(offset)
Moves the current selection by a numeric offset.
- Parameters:
-
Name Type Description offset
{number} the selection offset (a positive or negative number) - Returns:
- the index of the newly selected child, or -1 if none was selected
- Source:
- RapidContext_Widget_Popup.js, line 225
selectedChild() → {Node}
Returns the currently selected child node.
- Returns:
- {Node} the currently selected child node, or null if no node is selected
- Source:
- RapidContext_Widget_Popup.js, line 175
setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
- Parameters:
-
Name Type Description attrs
{Object} the widget and node attributes to set Properties
Name Type Attributes Description delay
{number} <optional>
the widget auto-hide delay in milliseconds, defaults to 5000 hidden
{boolean} <optional>
the hidden widget flag - Overrides:
- RapidContext.Widget#setAttrs
- Source:
- RapidContext_Widget_Popup.js, line 99
setStyle(styles)
Updates the CSS styles of this HTML DOM node. This method is
identical to MochiKit.Style.setStyle
, but uses "this" as the
first argument.
- Parameters:
-
Name Type Description styles
{Object} an object with the styles to set - Inherited From:
- RapidContext.Widget#setStyle
- Example:
-
widget.setStyle({ "font-size": "bold", "color": "red" });
- Source:
- RapidContext_Widget.js, line 288
show()
Shows this widget node if it was previously hidden. This method is
equivalent to calling setAttrs({ hidden: false })
. It is safe
for all types of widgets, since it only removes the widgetHidden
CSS class instead of setting the display
style property.
- Inherited From:
- RapidContext.Widget#show
- Source:
- RapidContext_Widget.js, line 456
toggleClass(…cls) → {boolean}
Toggles adding and removing the specified CSS class names to and from this HTML DOM node. If all the CSS classes are already set, they will be removed. Otherwise they will be added.
- Parameters:
-
Name Type Attributes Description cls
{string|Array} <repeatable>
the CSS class names to remove - Returns:
-
{boolean}
true
if the CSS classes were added, orfalse
otherwise - Inherited From:
- RapidContext.Widget#toggleClass
- Source:
- RapidContext_Widget.js, line 372
uid() → {string}
Returns the unique identifier for this DOM node. If a node id has already been set, that id will be returned. Otherwise a new id will be generated and assigned to the widget DOM node.
- Returns:
- {string} the the unique DOM node identifier
- Inherited From:
- RapidContext.Widget#uid
- Source:
- RapidContext_Widget.js, line 186
Events
onmenuselect
Emitted when a menu item is selected.
- Source:
- RapidContext_Widget_Popup.js, line 84
onhide
Emitted when the popup is hidden.
- Source:
- RapidContext_Widget_Popup.js, line 77
onshow
Emitted when the popup is shown.
- Source:
- RapidContext_Widget_Popup.js, line 70