Home

# Class goog.ui.HoverCard

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.

extends goog.ui.AdvancedTooltip

Instance Method Summary
| `cancelTrigger()` Abort pending hovercard showing, if any.
| `detachTempAnchor_((Element|null|undefined) anchor)` If given anchor is in the list of temporarily attached anchors, then detach and remove from the list.

`disposeInternal()`

Unattach 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, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `getAnchorElement() ⇒ ?Element` 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.
| `handleMouseOutAndBlur(?goog.events.BrowserEvent event)` If the mouse moves out of the trigger while we're being triggered, then cancel it.
| `handleMouseOver(?goog.events.BrowserEvent 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.
| `handleTriggerMouseOver_(?goog.events.Event e)` If the user mouses over an element with the correct tag and attribute, then trigger the hovercard for that element. If anchors could have children, then we also need to check the parent chain of the given element.
| `isAnchor_(?Node node) ⇒ boolean` This function can be overridden by passing a function as the first parameter to the constructor.
| `maybeCancelTrigger_()` If hovercard is in the process of being triggered, then cancel it.
| `maybeShow(?Element el, ?goog.positioning.AbstractPosition= 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.
| `onCancelTrigger()` This method gets called when we detect that a trigger event will not lead to the hovercard being shown.
| `onHide_(?Object= opt_target)` Make sure we detach from temp anchor when we are done displaying hovercard.
| `onTrigger(!goog.ui.HoverCard.TriggerEvent triggerEvent) ⇒ 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.
| `setCurrentAnchor_(?Element anchor)` Sets the current anchor element at the time that the hovercard is shown.
| `setMaxSearchSteps(number maxSearchSteps)` Sets the max number of levels to search up the dom if checking descendants.
| `triggerForElement(?Element anchorElement, ?goog.positioning.AbstractPosition= opt_pos, ?Object= opt_data)` Triggers the hovercard to show after a delay.