Show drop downs (ex: the select list of a ComboBox) or popups (ex: right-click context menus).
Methods
-
<static> close(popup)
-
Close specified popup and any popups that it parented. If no popup is specified, closes all popups.
Parameters:
Name Type Argument Description popup
module:delite/Widget <optional>
- Source:
-
<static> detach(widget)
-
Detach specified popup widget from document
Parameters:
Name Type Description widget
module:delite/Widget - Source:
-
<static> getTopPopup() → {module:delite/Widget}
-
Compute the closest ancestor popup that's not a child of another popup. Ex: For a TooltipDialog with a button that spawns a tree of menus, find the popup of the button.
- Source:
Returns:
- Type
- module:delite/Widget
-
<static> hide(widget)
-
Hide this popup widget (until it is ready to be shown). Initialization for widgets that will be used as popups.
Also puts widget inside a wrapper DIV (if not already in one).
If popup widget needs to layout it should do so when it is made visible, and popup._onShow() is called.
Parameters:
Name Type Description widget
module:delite/Widget - Source:
-
<static> moveOffScreen(widget) → {HTMLElement}
-
Moves the popup widget off-screen. Do not use this method to hide popups when not in use, because that will create an accessibility issue: the offscreen popup will still be in the tabbing order.
Parameters:
Name Type Description widget
module:delite/Widget - Source:
Returns:
- Type
- HTMLElement
-
<static> open(args) → {*}
-
Popup the widget at the specified position.
Note that whatever widget called delite/popup.open() should also require activationTracker and listen for delite-deactivated event to know that focus has moved somewhere else and thus the popup should be closed.
Parameters:
Name Type Description args
module:delite/popup.OpenArgs - Source:
Returns:
If orient !== center then returns the alignment of the popup relative to the anchor node.
- Type
- *
Examples
// Open at the mouse position popup.open({popup: menuWidget, x: evt.pageX, y: evt.pageY});
// Open the widget as a dropdown popup.open({parent: this, popup: menuWidget, around: this, onClose: function(){...}});
Type Definitions
-
OpenArgs
-
Arguments to
delite/popup#open()
method.Type:
- Object
- hitting ESC or TAB key
- using the popup widget's proprietary cancel mechanism (like a cancel button in a dialog), causing the widget to emit a "cancel" event
- Source:
Properties:
Name Type Description popup
module:delite/Widget The Widget to display.
parent
module:delite/Widget The button etc. that is displaying this popup.
around
Element | Rectangle DOM node (typically a button); place popup relative to this node. (Specify this or
x
andy
properties.)x
number Absolute horizontal position (in pixels) to place node at. (Specify this or
around
parameter.)y
number Absolute vertical position (in pixels) to place node at. (Specify this or
around
parameter.)orient
Array.<string> When the
around
parameter is specified,orient
should be a list of positions to try, ex.[ "below", "above" ]
delite/popup.open()
tries to position the popup according to each specified position, in order, until the popup appears fully within the viewport. The default value is["below", "above"]
. When an(x,y)
position is specified rather than anaround
node,orient
is either "R" or "L". R (for right) means that it tries to put the popup to the right of the mouse, specifically positioning the popup's top-right corner at the mouse position, and if that doesn't fit in the viewport, then it tries, in order, the bottom-right corner, the top left corner, and the top-right corner.Alternately,
orient
can be an array["center"]
, which pops up the specified node in the center of the viewport, like a dialog. It will shrink the size of the node if necessary, in which case the node must be designed so that scrolling occurs in the right place.onCancel
function Callback when user has canceled the popup by:
onExecute
function Callback when user has executed the popup by using the popup widget's proprietary execute mechanism (like an OK button in a dialog, or clicking a choice in a dropdown list), causing the widget to emit an "execute" or "change" event.
onClose
function Callback whenever this popup is closed.
padding
Position Adding a buffer around the opening position. This is only used when
around
is not set.maxHeight
number The maximum height for the popup. Any popup taller than this will have scroll bars. Set to
Infinity
for no max height. Default is to limit height to available space in viewport, above or below thearoundNode
or specifiedx/y
position.