goog.ui.HoverCard
Classgoog.ui.HoverCard
> goog.ui.AdvancedTooltip
> goog.ui.Tooltip
> goog.ui.Popup
> goog.ui.PopupBase
> goog.events.EventTarget
> goog.Disposable
goog.ui.HoverCard(isAnchor, opt_checkDescendants, opt_domHelper,
opt_triggeringDocument)
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 {@code triggerForElement}, shown without a delay by calling {@code showForElement}, or triggered over other elements by calling {@code attach}. For the latter two cases, the application is responsible for calling {@code 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.
isAnchor
{Function
|Object
}
opt_checkDescendants
{boolean
=}
opt_domHelper
{goog.dom.DomHelper
=}
opt_triggeringDocument
{Document
=}
goog.ui.HoverCard.EventType
EnumEnum for event type fired by HoverCard. … more
goog.ui.HoverCard.TriggerEvent
ClassCreate a trigger event for specified anchor and optional data. … more
.addEventListener(type, handler, opt_capture, opt_handlerScope)
Inherited from goog.events.EventTarget
.
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. Supported for legacy but use goog.events.listen(src, type, handler) instead.
type
{string
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.addOnDisposeCallback(callback, opt_scope)
Inherited from goog.Disposable
.
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
callback
{!Function
}
opt_scope
{Object
=}
.anchor
[protected] {Element
|undefined
}Inherited from goog.ui.Tooltip
.
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.
.attach(el)
Inherited from goog.ui.Tooltip
.
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.
el
{Element
|string
}
.cancelTrigger()
Abort pending hovercard showing, if any.
.className
{string
}Inherited from goog.ui.Tooltip
.
CSS class name for tooltip.
.clearHideTimer()
[protected]Inherited from goog.ui.Tooltip
.
Helper method called to clear the close timer.
.clearShowTimer()
[protected]Inherited from goog.ui.Tooltip
.
Helper method called to clear the show timer.
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.detach(opt_el)
Inherited from goog.ui.Tooltip
.
Detach from element(s).
opt_el
{Element
|string
=}
.dispatchEvent(e)
Inherited from goog.events.EventTarget
.
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.
e
{string
|Object
|goog.events.Event
}
boolean
}
.dispose()
Inherited from goog.Disposable
.
Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
void
}
.disposeInternal()
.getActiveElement()
Inherited from goog.ui.Tooltip
.
Element
}
.getAnchorElement()
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.
Element
}
.getAnchorFromElement(el)
[protected]Inherited from goog.ui.Tooltip
.
Find anchor containing the given element, if any.
el
{Element
}
Element
}
.getAutoHide()
Inherited from goog.ui.PopupBase
.
Returns whether the Popup dismisses itself when the user clicks outside of it.
boolean
}
.getAutoHideRegion()
Inherited from goog.ui.PopupBase
.
Returns the region inside which the Popup dismisses itself when the user clicks, or null if it's the entire document.
Element
}
.getChildTooltip()
[protected]Inherited from goog.ui.Tooltip
.
goog.ui.Tooltip
}
.getCursorTracking()
Inherited from goog.ui.AdvancedTooltip
.
boolean
}
.getCursorTrackingHideDelayMs()
Inherited from goog.ui.AdvancedTooltip
.
number
}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getDomHelper()
Inherited from goog.ui.Tooltip
.
Returns the dom helper that is being used on this component.
goog.dom.DomHelper
}
.getElement()
Inherited from goog.ui.PopupBase
.
Returns the dom element that should be used for the popup.
Element
}
.getElements()
[protected]Inherited from goog.ui.Tooltip
.
goog.structs.Set
}
.getEnableCrossIframeDismissal()
Inherited from goog.ui.PopupBase
.
boolean
}
.getHideDelayMs()
Inherited from goog.ui.AdvancedTooltip
.
Override hide delay with cursor tracking hide delay while tracking.
number
}
.getHideOnEscape()
Inherited from goog.ui.PopupBase
.
boolean
}
.getHotSpotPadding()
Inherited from goog.ui.AdvancedTooltip
.
goog.math.Box
}
.getHtml()
Inherited from goog.ui.Tooltip
.
string
}
.getLastHideTime()
Inherited from goog.ui.PopupBase
.
Returns the time when the popup was last hidden.
number
}
.getLastShowTime()
Inherited from goog.ui.PopupBase
.
Returns the time when the popup was last shown.
number
}
.getMargin()
Inherited from goog.ui.Popup
.
Returns the margin to place around the popup.
goog.math.Box
?}
.getParentEventTarget()
Inherited from goog.events.EventTarget
.
Returns the parent of this event target to use for bubbling.
goog.events.EventTarget
}
.getPinnedCorner()
Inherited from goog.ui.Popup
.
Returns the corner of the popup to used in the positioning algorithm.
goog.positioning.Corner
}
.getPosition()
Inherited from goog.ui.Popup
.
goog.positioning.AbstractPosition
}
.getPositioningStrategy(activationType)
[protected]Inherited from goog.ui.Tooltip
.
Return a Position instance for repositioning the tooltip. Override in subclasses to customize the way repositioning is done.
activationType
{goog.ui.Tooltip.Activation
}
goog.positioning.AbstractPosition
}
.getShowDelayMs()
Inherited from goog.ui.Tooltip
.
number
}
.getState()
Inherited from goog.ui.Tooltip
.
goog.ui.Tooltip.State
}
.getText()
Inherited from goog.ui.Tooltip
.
string
}
.getType()
Inherited from goog.ui.PopupBase
.
goog.ui.PopupBase.Type
}
.handleFocus(event)
[protected]Inherited from goog.ui.Tooltip
.
Handler for focus events.
event
{goog.events.BrowserEvent
}
.handleMouseMove(event)
[protected]Inherited from goog.ui.AdvancedTooltip
.
Handler for mouse move events.
event
{goog.events.BrowserEvent
}
.handleMouseOutAndBlur(event)
If the mouse moves out of the trigger while we're being triggered, then cancel it.
event
{goog.events.BrowserEvent
}
.handleMouseOver(event)
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.
event
{goog.events.BrowserEvent
}
.handleTooltipMouseOut(event)
[protected]Inherited from goog.ui.Tooltip
.
Handler for mouse out events for the tooltip element.
event
{goog.events.BrowserEvent
}
.handleTooltipMouseOver(event)
[protected]Inherited from goog.ui.AdvancedTooltip
.
Handler for mouse over events for the tooltip element.
event
{goog.events.BrowserEvent
}
.hasActiveChild()
[protected]Inherited from goog.ui.Tooltip
.
boolean
}
.isCoordinateInTooltip(coord)
Inherited from goog.ui.AdvancedTooltip
.
Checks whether the supplied coordinate is inside the tooltip, including padding if any.
coord
{goog.math.Coordinate
}
boolean
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isMouseInTooltip()
Inherited from goog.ui.AdvancedTooltip
.
Returns true if the mouse is in the tooltip.
boolean
}
.isOrWasRecentlyVisible()
Inherited from goog.ui.PopupBase
.
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 alrady 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); }
boolean
}
.isVisible()
Inherited from goog.ui.PopupBase
.
Returns whether the popup is currently visible.
boolean
}
.maybeHide(el)
Inherited from goog.ui.AdvancedTooltip
.
Called by timer from mouse out handler. Hides tooltip if cursor is still outside element and tooltip.
el
{Element
}
.maybeShow(el, opt_pos)
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.
el
{Element
}
opt_pos
{goog.positioning.AbstractPosition
=}
.onBeforeHide_(opt_target)
[protected]Inherited from goog.ui.PopupBase
.
Called before the popup is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
opt_target
{Object
=}
boolean
}
.onBeforeShow()
[protected]Inherited from goog.ui.Tooltip
.
Called before the popup is shown.
boolean
}
.onCancelTrigger()
[protected]This method gets called when we detect that a trigger event will not lead to the hovercard being shown.
.onHide_()
[protected]Make sure we detach from temp anchor when we are done displaying hovercard.
.onShow_()
[protected]Inherited from goog.ui.AdvancedTooltip
.
Called after the popup is shown.
.onTrigger(triggerEvent)
[protected]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.
triggerEvent
{!goog.ui.HoverCard.TriggerEvent
}
boolean
}
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.removeEventListener(type, handler, opt_capture, opt_handlerScope)
Inherited from goog.events.EventTarget
.
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.
type
{string
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.reposition()
Inherited from goog.ui.Popup
.
Repositions the popup according to the current state.
.resetHotSpot
[deprecated]Deprecated. Not ever necessary to call this function. Hot spot is calculated as neccessary.
Inherited from goog.ui.AdvancedTooltip
.
Forces the recalculation of the hotspot on the next mouse over event.
.setActiveElement(activeEl)
[protected]Inherited from goog.ui.Tooltip
.
activeEl
{Element
}
.setAutoHide(autoHide)
Inherited from goog.ui.PopupBase
.
Sets whether the Popup dismisses itself when the user clicks outside of it.
autoHide
{boolean
}
.setAutoHideRegion(element)
Inherited from goog.ui.PopupBase
.
Sets the region inside which the Popup dismisses itself when the user clicks.
element
{Element
}
.setCursorTracking(b)
Inherited from goog.ui.AdvancedTooltip
.
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.
b
{boolean
}
.setCursorTrackingHideDelayMs(delay)
Inherited from goog.ui.AdvancedTooltip
.
Sets delay in milliseconds before tooltips are hidden if cursor tracking is enabled and the cursor is moving away from the tooltip.
delay
{number
}
.setElement(el)
Inherited from goog.ui.Tooltip
.
Sets tooltip element.
el
{Element
}
.setEnableCrossIframeDismissal(enable)
Inherited from goog.ui.PopupBase
.
Sets whether clicks in other iframes should dismiss this popup. In some cases it should be disabled, because it can cause spurious
enable
{boolean
}
.setHideDelayMs(delay)
Inherited from goog.ui.Tooltip
.
Sets delay in milliseconds before tooltip is hidden once the cursor leavs the element.
delay
{number
}
.setHideOnEscape(hideOnEscape)
Inherited from goog.ui.PopupBase
.
Sets whether the Popup dismisses itself on the escape key.
hideOnEscape
{boolean
}
.setHotSpotPadding(opt_box)
Inherited from goog.ui.AdvancedTooltip
.
Sets margin around the tooltip where the cursor is allowed without dismissing the tooltip.
opt_box
{goog.math.Box
=}
.setHtml(str)
Inherited from goog.ui.Tooltip
.
Sets tooltip message as HTML markup.
str
{string
}
.setMargin(arg1, opt_arg2, opt_arg3, opt_arg4)
Inherited from goog.ui.Popup
.
Sets the margin to place around the popup.
arg1
{goog.math.Box
|number
|null
}
opt_arg2
{number
=}
opt_arg3
{number
=}
opt_arg4
{number
=}
.setMaxSearchSteps(maxSearchSteps)
Sets the max number of levels to search up the dom if checking descendants.
maxSearchSteps
{number
}
.setParentEventTarget(parent)
Inherited from goog.events.EventTarget
.
Sets the parent of this event target to use for bubbling.
parent
{goog.events.EventTarget
?}
.setPinnedCorner(corner)
Inherited from goog.ui.Popup
.
Sets the corner of the popup to used in the positioning algorithm.
corner
{goog.positioning.Corner
}
.setPosition(position)
Inherited from goog.ui.Popup
.
Sets the position helper object associated with the popup.
position
{goog.positioning.AbstractPosition
}
.setRequireInteraction(requireInteraction)
Inherited from goog.ui.Tooltip
.
Sets whether tooltip requires the mouse to have moved or the anchor receive focus before the tooltip will be shown.
requireInteraction
{boolean
}
.setShouldHideAsync(b)
Inherited from goog.ui.PopupBase
.
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
b
{boolean
}
.setShowDelayMs(delay)
Inherited from goog.ui.Tooltip
.
Sets delay in milliseconds before tooltip is displayed for an element.
delay
{number
}
.setText(str)
Inherited from goog.ui.Tooltip
.
Sets tooltip message as plain text.
str
{string
}
.setTransition(opt_showTransition, opt_hideTransition)
Inherited from goog.ui.PopupBase
.
Sets transition animation on showing and hiding the popup.
opt_showTransition
{goog.fx.Transition
=}
opt_hideTransition
{goog.fx.Transition
=}
.setType(type)
Inherited from goog.ui.PopupBase
.
Specifies the type of popup to use.
type
{goog.ui.PopupBase.Type
}
.setVisible(visible)
Inherited from goog.ui.PopupBase
.
Sets whether the popup should be visible. After this method returns, isVisible() will always return the new state, even if there is a transition.
visible
{boolean
}
.shouldHideAsync()
Inherited from goog.ui.PopupBase
.
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
boolean
}
.showForElement(el, opt_pos)
Inherited from goog.ui.Tooltip
.
Shows tooltip for a specific element.
el
{Element
}
opt_pos
{goog.positioning.AbstractPosition
=}
.startHideTimer()
[protected]Inherited from goog.ui.Tooltip
.
Helper method called to start the close timer.
.startShowTimer(el, opt_pos)
[protected]Inherited from goog.ui.Tooltip
.
Helper method, starts timer that calls maybeShow. Parameters are passed to the maybeShow method.
el
{Element
}
opt_pos
{goog.positioning.AbstractPosition
=}
.triggerForElement(anchorElement, opt_pos, opt_data)
Triggers the hovercard to show after a delay.
anchorElement
{Element
}
opt_pos
{goog.positioning.AbstractPosition
=}
opt_data
{Object
=}