goog.ui.HoverCard
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
Create a hover card object. Hover cards extend tooltips in that they don't have to be manually attached to each element that can cause them to display. Instead, you can create a function that gets called when the mouse goes over any element on your page, and returns whether or not the hovercard should be shown for that element.
Alternatively, you can define a map of tag names to the attribute name each tag should have for that tag to trigger the hover card. See example below.
Hovercards can also be triggered manually by calling
triggerForElement
, shown without a delay by calling
showForElement
, or triggered over other elements by calling
attach
. For the latter two cases, the application is responsible
for calling detach
when finished.
HoverCard objects fire a TRIGGER event when the mouse moves over an element that can trigger a hovercard, and BEFORE_SHOW when the hovercard is about to be shown. Clients can respond to these events and can prevent the hovercard from being triggered or shown.
new HoverCard( isAnchor, opt_checkDescendants, opt_domHelper, opt_triggeringDocument )
Parameters |
|
---|
Instance Methods
this.addAutoHidePartner( partner ) → void
void
Mouse events that occur within an autoHide partner will not hide a popup set to autoHide.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.addEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.attach( el ) → void
void
Attach to element. Tooltip will be displayed when the cursor is over the element or when the element has been active for a few milliseconds.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.cancelTrigger() → void
void
Abort pending hovercard showing, if any.
this.clearHideTimer() → void
void
Helper method called to clear the close timer.
this.clearShowTimer() → void
void
Helper method called to clear the show timer.
this.detach( opt_el ) → void
void
Detach from element(s).
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.dispatchEvent( e ) → boolean
boolean
Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object.
If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
Overrides | |
---|---|
Parameters | None. |
this.fireListeners<EVENTOBJ>( type, capture, eventObject ) → boolean
boolean
Fires all registered listeners in this listenable for the given type and capture mode, passing them the given eventObject. This does not perform actual capture/bubble. Only implementors of the interface should be using this.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
| ||||||||||||
Returns |
|
this.getActiveElement() → (Element|null)
(Element|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getAnchorElement() → (Element|null)
(Element|null)
Gets the DOM element that triggered the current hovercard. Note that in the TRIGGER or CANCEL_TRIGGER events, the current hovercard's anchor may not be the one that caused the event, so use the event's anchor property instead.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAnchorFromElement( el ) → (Element|null)
(Element|null)
Find anchor containing the given element, if any.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getAutoHide() → boolean
boolean
Returns whether the Popup dismisses itself when the user clicks outside of it.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getAutoHideRegion() → (Element|null)
(Element|null)
Returns the region inside which the Popup dismisses itself when the user clicks, or null if it's the entire document.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getChildTooltip() → (goog.ui.Tooltip|null)
(goog.ui.Tooltip|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getCursorTracking() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getCursorTrackingHideDelayMs() → number
number
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getDomHelper() → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Returns the dom helper that is being used on this component.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElement() → (Element|null)
(Element|null)
Returns the dom element that should be used for the popup.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElements() → (goog.structs.Set|null)
(goog.structs.Set|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEnableCrossIframeDismissal() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHandler<T>() → (goog.events.EventHandler<T>|null)
(goog.events.EventHandler<T>|null)
Returns the event handler for the popup. All event listeners belonging to
this handler are removed when the tooltip is hidden. Therefore,
the recommended usage of this handler is to listen on events in
#onShow
.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHideDelayMs() → number
number
Override hide delay with cursor tracking hide delay while tracking.
Defined by | |||
---|---|---|---|
Overrides | |||
Parameters | None. | ||
Returns |
|
this.getHideOnEscape() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHotSpotPadding() → (goog.math.Box|null)
(goog.math.Box|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHtml() → string
string
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getLastHideTime() → number
number
Returns the time when the popup was last hidden.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getLastShowTime() → number
number
Returns the time when the popup was last shown.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getListener<SCOPE, EVENTOBJ>( type, listener, capture, opt_listenerScope ) → (goog.events.ListenableKey|null)
(goog.events.ListenableKey|null)
Gets the goog.events.ListenableKey for the event or null if no such listener is in use.
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.getListeners<EVENTOBJ>( type, capture ) → Array<goog.events.ListenableKey>
Array<goog.events.ListenableKey>
Gets all listeners in this listenable for the given type and capture mode.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.getMargin() → (goog.math.Box|null)
(goog.math.Box|null)
Returns the margin to place around the popup.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getParentEventTarget() → (goog.events.Listenable|null)
(goog.events.Listenable|null)
Returns the parent of this event target to use for capture/bubble mechanism.
NOTE(chrishenry): The name reflects the original implementation of
custom event target (goog.events.EventTarget
). We decided
that changing the name is not worth it.
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.getPinnedCorner() → goog.positioning.Corner
goog.positioning.Corner
Returns the corner of the popup to used in the positioning algorithm.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getPosition() → (goog.positioning.AbstractPosition|null)
(goog.positioning.AbstractPosition|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getPositioningStrategy( activationType ) → goog.positioning.AbstractPosition
goog.positioning.AbstractPosition
Return a Position instance for repositioning the tooltip. Override in subclasses to customize the way repositioning is done.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getShowDelayMs() → number
number
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getState() → goog.ui.Tooltip.State
goog.ui.Tooltip.State
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getText() → string
string
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getType() → goog.ui.PopupBase.Type
goog.ui.PopupBase.Type
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.handleFocus( event ) → void
void
Handler for focus events.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleMouseMove( event ) → void
void
Handler for mouse move events.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.handleMouseOutAndBlur( event ) → void
void
If the mouse moves out of the trigger while we're being triggered, then cancel it.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleMouseOver( event ) → void
void
This mouse over event is only received if the anchor is already attached. If it was attached manually, then it may need to be triggered.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleTooltipMouseOut( event ) → void
void
Handler for mouse out events for the tooltip element.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleTooltipMouseOver( event ) → void
void
Handler for mouse over events for the tooltip element.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.hasActiveChild() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.hasListener<EVENTOBJ>( opt_type, opt_capture ) → boolean
boolean
Whether there is any active listeners matching the specified signature. If either the type or capture parameters are unspecified, the function will match on the remaining criteria.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.hidePopupElement() → void
void
Hides the popup element.
this.isCoordinateInTooltip( coord ) → boolean
boolean
Checks whether the supplied coordinate is inside the tooltip, including padding if any.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isMouseInTooltip() → boolean
boolean
Returns true if the mouse is in the tooltip.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isOrWasRecentlyVisible() → boolean
boolean
Returns whether the popup is currently visible or was visible within about 150 ms ago. This is used by clients to handle a very specific, but common, popup scenario. The button that launches the popup should close the popup on mouse down if the popup is already open. The problem is that the popup closes itself during the capture phase of the mouse down and thus the button thinks it's hidden and this should show it again. This method provides a good heuristic for clients. Typically in their event handler they will have code that is:
if (menu.isOrWasRecentlyVisible()) { menu.setVisible(false); } else { ... // code to position menu and initialize other state menu.setVisible(true); }
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isVisible() → boolean
boolean
Returns whether the popup is currently visible.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.listen<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.listenOnce<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener that is removed automatically after the listener fired once.
If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.maybeHide( el ) → void
void
Called by timer from mouse out handler. Hides tooltip if cursor is still outside element and tooltip.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.maybeShow( el, opt_pos ) → void
void
Called by timer from mouse over handler. If this is called and the hovercard is not shown for whatever reason, then send a cancel trigger event.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.onBeforeHide( opt_target ) → boolean
boolean
Called before the popup is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.onBeforeShow() → boolean
boolean
Called before the popup is shown.
Defined by | |||
---|---|---|---|
Overrides | |||
Parameters | None. | ||
Returns |
|
this.onCancelTrigger() → void
void
This method gets called when we detect that a trigger event will not lead to the hovercard being shown.
this.onHide( opt_target ) → void
void
Make sure we detach from temp anchor when we are done displaying hovercard.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onShow() → void
void
Called after the popup is shown.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.onTrigger( triggerEvent ) → boolean
boolean
Called when an element triggers the hovercard. This will return false if an event handler sets preventDefault to true, which will prevent the hovercard from being shown.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeAllListeners( opt_type ) → number
number
Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.removeAutoHidePartner( partner ) → void
void
Removes a previously registered auto hide partner.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.reposition() → void
void
Repositions the popup according to the current state.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.resetHotSpot() → void
void
Forces the recalculation of the hotspot on the next mouse over event.
warning Deprecated | Not ever necessary to call this function. Hot spot is calculated as necessary. |
---|
Defined by | |
---|---|
Parameters | None. |
this.setActiveElement( activeEl ) → void
void
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAutoHide( autoHide ) → void
void
Sets whether the Popup dismisses itself when the user clicks outside of it.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAutoHideRegion( element ) → void
void
Sets the region inside which the Popup dismisses itself when the user clicks.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setCursorTracking( b ) → void
void
Sets whether to track the cursor and thereby close the tooltip if it moves away from the tooltip and keep it open if it moves towards it.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setCursorTrackingHideDelayMs( delay ) → void
void
Sets delay in milliseconds before tooltips are hidden if cursor tracking is enabled and the cursor is moving away from the tooltip.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setElement( el ) → void
void
Sets tooltip element.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.setEnableCrossIframeDismissal( enable ) → void
void
Sets whether clicks in other iframes should dismiss this popup. In some cases it should be disabled, because it can cause spurious
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHideDelayMs( delay ) → void
void
Sets delay in milliseconds before tooltip is hidden once the cursor leavs the element.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHideOnEscape( hideOnEscape ) → void
void
Sets whether the Popup dismisses itself on the escape key.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHotSpotPadding( opt_box ) → void
void
Sets margin around the tooltip where the cursor is allowed without dismissing the tooltip.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setMargin( arg1, opt_arg2, opt_arg3, opt_arg4 ) → void
void
Sets the margin to place around the popup.
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setMaxSearchSteps( maxSearchSteps ) → void
void
Sets the max number of levels to search up the dom if checking descendants.
Parameters |
|
---|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPinnedCorner( corner ) → void
void
Sets the corner of the popup to used in the positioning algorithm.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPosition( position ) → void
void
Sets the position helper object associated with the popup.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setRequireInteraction( requireInteraction ) → void
void
Sets whether tooltip requires the mouse to have moved or the anchor receive focus before the tooltip will be shown.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setSafeHtml( html ) → void
void
Sets tooltip message as HTML markup.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setShouldHideAsync( b ) → void
void
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setShowDelayMs( delay ) → void
void
Sets delay in milliseconds before tooltip is displayed for an element.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setTargetForTesting( target ) → void
void
Sets the target to be used for event.target
when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable
.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setText( str ) → void
void
Sets tooltip message as plain text.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setTransition( opt_showTransition, opt_hideTransition ) → void
void
Sets transition animation on showing and hiding the popup.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setType( type ) → void
void
Specifies the type of popup to use.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setVisible( visible ) → void
void
Sets whether the popup should be visible. After this method returns, isVisible() will always return the new state, even if there is a transition.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.shouldHideAsync() → boolean
boolean
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.showForElement( el, opt_pos ) → void
void
Shows tooltip for a specific element.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.showPopupElement() → void
void
Shows the popup element.
this.startHideTimer() → void
void
Helper method called to start the close timer.
this.startShowTimer( el, opt_pos ) → void
void
Helper method, starts timer that calls maybeShow. Parameters are passed to the maybeShow method.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.triggerForElement( anchorElement, opt_pos, opt_data ) → void
void
Triggers the hovercard to show after a delay.
Parameters |
|
---|
this.unlisten<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → boolean
boolean
Removes an event listener which was added with listen() or listenOnce().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.unlistenByKey( key ) → boolean
boolean
Removes an event listener which was added with listen() by the key returned by listen().
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
Instance Properties
this.anchor → (Element|null|undefined)
(Element|null|undefined)
Element that triggered the tooltip. Note that if a second element triggers this tooltip, anchor becomes that second element, even if its show is cancelled and the original tooltip survives.
this.className → string
string
CSS class name for tooltip.
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.cursorPosition → goog.math.Coordinate
goog.math.Coordinate
Cursor position relative to the page.
this.hideTimer → (number|undefined)
(number|undefined)
Timer for when to hide.
this.showTimer → (number|undefined)
(number|undefined)
Timer for when to show.