Home

# Class goog.ui.PopupBase

The PopupBase class provides functionality for showing and hiding a generic container element. It also provides the option for hiding the popup element if the user clicks outside the popup or the popup loses focus.

extends goog.events.EventTarget

Instance Method Summary
| `continueHidingPopup_(?Object= opt_target)` Continues hiding the popup. This is a continuation from hide_. It is a separate method so that we can add a transition before hiding.

`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
    };

| `ensureNotVisible_()` Helper to throw exception if the popup is showing.
| `getAutoHide() ⇒ boolean` Returns whether the Popup dismisses itself when the user clicks outside of it.
| `getAutoHideRegion() ⇒ ?Element` Returns the region inside which the Popup dismisses itself when the user clicks, or null if it's the entire document.
| `getElement() ⇒ ?Element` Returns the dom element that should be used for the popup.
| `getEnableCrossIframeDismissal() ⇒ boolean`
| `getHideOnEscape() ⇒ boolean`
| `getLastHideTime() ⇒ number` Returns the time when the popup was last hidden.
| `getLastShowTime() ⇒ number` Returns the time when the popup was last shown.
| `getType() ⇒ ?goog.ui.PopupBase.Type`
| `hidePopupElement_()` Hides the popup element.
| `hide_(?Object= opt_target) ⇒ boolean` Hides the popup. This call is idempotent.

`isOrWasRecentlyVisible() ⇒ 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 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); }

| `isVisible() ⇒ boolean` Returns whether the popup is currently visible.
| `moveOffscreen_()` Hides the popup by moving it offscreen.
| `onBeforeHide_(?Object= opt_target) ⇒ 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.
| `onBeforeShow() ⇒ boolean` Called before the popup is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
| `onDocumentBlur_(?goog.events.BrowserEvent e)` Deactivate handler(IE) and blur handler (other browsers) for document. Used to hide the popup for auto-hide mode.
| `onDocumentKeyDown_(?goog.events.BrowserEvent e)` Handles key-downs on the document to handle the escape key.
| `onDocumentMouseDown_(?goog.events.BrowserEvent e)` Mouse down handler for the document on capture phase. Used to hide the popup for auto-hide mode.
| `onHide_(?Object= opt_target)` Called after the popup is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
| `onShow_()` Called after the popup is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
| `reposition()` Repositions the popup according to the current state. Should be overriden by subclases.
| `setAutoHide(boolean autoHide)` Sets whether the Popup dismisses itself when the user clicks outside of it.
| `setAutoHideRegion(?Element element)` Sets the region inside which the Popup dismisses itself when the user clicks.
| `setElement(?Element elt)` Specifies the dom element that should be used for the popup.
| `setEnableCrossIframeDismissal(boolean enable)` Sets whether clicks in other iframes should dismiss this popup. In some cases it should be disabled, because it can cause spurious
| `setHideOnEscape(boolean hideOnEscape)` Sets whether the Popup dismisses itself on the escape key.
| `setShouldHideAsync(boolean b)` Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
| `setTransition(?goog.fx.Transition= opt_showTransition, ?goog.fx.Transition= opt_hideTransition)` Sets transition animation on showing and hiding the popup.
| `setType(?goog.ui.PopupBase.Type type)` Specifies the type of popup to use.
| `setVisible(boolean visible)` Sets whether the popup should be visible.
| `shouldDebounce_() ⇒ boolean`
| `shouldHideAsync() ⇒ boolean` Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
| `showPopupElement()` Shows the popup element.
| `show_()` Does the work to show the popup.