Make an object an overlay (prototype or instance).
Static Properties
-
Coral.mixin.overlay.focusOnShow {String}
-
Properties:
Name Type Value Description ON String on When the overlay is opened, it will be focused. OFF String off The overlay will not focus itself when opened. -
Coral.mixin.overlay.returnFocus {String}
-
Properties:
Name Type Value Description ON String on When the overlay is closed, the element that was focused before the it was shown will be focused again. OFF String off Nothing will be focused when the overlay is closed. -
Coral.mixin.overlay.trapFocus {String}
-
Properties:
Name Type Value Description ON String on Focus is trapped such that the use cannot focus outside of the overlay. OFF String off The user can focus outside the overlay as normal.
Focus behavior options.
Return focus options.
Focus trap options.
Instance Properties
-
instance.focusOnShow {Coral.mixin.overlay.focusOnShow | HTMLElement | String}
-
- Default Value:
- HTML Attribute:
- focusonshow
-
instance.open {Boolean}
Reflected -
- Default Value:
- false
- HTML Attribute:
- open
-
instance.returnFocus {Coral.mixin.overlay.returnFocus}
-
- Default Value:
- Coral.mixin.overlay.returnFocus.OFF
- HTML Attribute:
- returnfocus
-
instance.trapFocus {Coral.mixin.overlay.trapFocus}
-
- Default Value:
- Coral.mixin.overlay.trapFocus.OFF
- HTML Attribute:
- trapfocus
Whether to focus the overlay, when opened or not. By default the overlay itself will get the focus. It also
accepts an instance of HTMLElement or a selector like ':first-child' or 'button:last-of-type'. If the selector
returns multiple elements, it will focus the first element inside the overlay that matches the selector.
Whether this overlay is open or not.
Whether to return focus to the previously focused element when closed.
Whether to trap tabs and keep them within the overlay.
Methods
-
instance.hide
-
- Returns:
-
this, chainable {Coral.Component}
-
instance.returnFocusTo
-
- Parameters:
-
Name Type Description element HTMLElement The element to return focus to. This must be a DOM element, not a jQuery object or selector. - Returns:
-
this, chainable {Coral.Component}
-
instance.show
-
- Returns:
-
this, chainable {Coral.Component}
Close the overlay.
Set the element that focus should be returned to when the overlay is hidden.
Open the overlay and set the z-index accordingly.
Events
-
coral-overlay:beforeclose
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.preventDefault function Call to stop the overlay from closing.
-
coral-overlay:beforeopen
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.preventDefault function Call to stop the overlay from opening.
-
coral-overlay:close
-
- Callback Parameters:
-
Name Type Description event Object Event object.
-
coral-overlay:open
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Triggerred before the component is closed with
hide()
or instance.open = false
.
Triggerred before the component is opened with
show()
or instance.open = true
.
Triggerred after the component is closed with
hide()
or instance.open = false
Triggerred after the overlay is opened with
show()
or instance.open = true