goog.ui.Tooltip
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
Tooltip widget. Can be attached to one or more elements and is shown, with a slight delay, when the cursor is over the element or the element gains focus.
new Tooltip( opt_el, opt_str, opt_domHelper )
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.
Parameters |
|
---|
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).
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)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAnchorFromElement( el ) → (Element|null)
(Element|null)
Find anchor containing the given element, if any.
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)
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.
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)
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
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHideOnEscape() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHtml() → string
string
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getShowDelayMs() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getState() → goog.ui.Tooltip.State
goog.ui.Tooltip.State
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getText() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getType() → goog.ui.PopupBase.Type
goog.ui.PopupBase.Type
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.handleFocus( event ) → void
void
this.handleMouseMove( event ) → void
void
Handler for mouse move events.
Parameters |
|
---|
this.handleMouseOutAndBlur( event ) → void
void
Handler for mouse out and blur events.
Parameters |
|
---|
this.handleMouseOver( event ) → void
void
Handler for mouse over events.
Parameters |
|
---|
this.handleTooltipMouseOut( event ) → void
void
Handler for mouse out events for the tooltip element.
Parameters |
|
---|
this.handleTooltipMouseOver( event ) → void
void
Handler for mouse over events for the tooltip element.
Parameters |
|
---|
this.hasActiveChild() → boolean
boolean
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
Returns true if the coord is in the tooltip.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified 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, or if a child of tooltip has the focus.
Parameters |
|
---|
this.maybeShow( el, opt_pos ) → void
void
Called by timer from mouse over handler. Shows tooltip if cursor is still over the same element.
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.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.onHide( opt_target ) → void
void
Called after the popup is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onShow() → void
void
Called after the popup is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
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.setActiveElement( activeEl ) → void
void
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.setElement( el ) → void
void
Sets tooltip element.
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.
Parameters |
|
---|
this.setHideOnEscape( hideOnEscape ) → void
void
Sets whether the Popup dismisses itself on the escape key.
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.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.
Parameters |
|
---|
this.setSafeHtml( html ) → void
void
Sets tooltip message as HTML markup.
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.
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.
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.
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.
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.