goog.ui.PopupBase
Classgoog.ui.PopupBase
> goog.events.EventTarget
> goog.Disposable
goog.ui.PopupBase(opt_element, opt_type)
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.
opt_element
{Element
=}
opt_type
{goog.ui.PopupBase.Type
=}
.DEBOUNCE_DELAY_MS
{number
}A time in ms used to debounce events that happen right after each other. A note about why this is necessary. There are two cases to consider. First case, a popup will usually see a focus event right after it's launched because it's typical for it to be launched in a mouse-down event which will then move focus to the launching button. We don't want to think this is a separate user action moving focus. Second case, a user clicks on the launcher button to close the menu. In that case, we'll close the menu in the focus event and then show it again because of the mouse down event, even though the intention is to just close the menu. This workaround appears to be the least intrusive fix.
goog.ui.PopupBase.EventType
EnumConstants for event type fired by Popup … more
goog.ui.PopupBase.Type
EnumConstants for type of Popup … 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
=}
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.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()
[protected]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 };
.getAutoHide()
Returns whether the Popup dismisses itself when the user clicks outside of it.
boolean
}
.getAutoHideRegion()
Returns the region inside which the Popup dismisses itself when the user clicks, or null if it's the entire document.
Element
}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getElement()
Returns the dom element that should be used for the popup.
Element
}
.getEnableCrossIframeDismissal()
boolean
}
.getHideOnEscape()
boolean
}
.getLastHideTime()
Returns the time when the popup was last hidden.
number
}
.getLastShowTime()
Returns the time when the popup was last shown.
number
}
.getParentEventTarget()
Inherited from goog.events.EventTarget
.
Returns the parent of this event target to use for bubbling.
goog.events.EventTarget
}
.getType()
goog.ui.PopupBase.Type
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isOrWasRecentlyVisible()
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()
Returns whether the popup is currently visible.
boolean
}
.onBeforeHide_(opt_target)
[protected]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]Called before the popup is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
boolean
}
.onHide_(opt_target)
[protected]Called after 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
=}
.onShow_()
[protected]Called after the popup is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
.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
Repositions the popup according to the current state. Should be overriden by subclases.
.setAutoHide(autoHide)
Sets whether the Popup dismisses itself when the user clicks outside of it.
autoHide
{boolean
}
.setAutoHideRegion(element)
Sets the region inside which the Popup dismisses itself when the user clicks.
element
{Element
}
.setElement(elt)
Specifies the dom element that should be used for the popup.
elt
{Element
}
.setEnableCrossIframeDismissal(enable)
Sets whether clicks in other iframes should dismiss this popup. In some cases it should be disabled, because it can cause spurious
enable
{boolean
}
.setHideOnEscape(hideOnEscape)
Sets whether the Popup dismisses itself on the escape key.
hideOnEscape
{boolean
}
.setParentEventTarget(parent)
Inherited from goog.events.EventTarget
.
Sets the parent of this event target to use for bubbling.
parent
{goog.events.EventTarget
?}
.setShouldHideAsync(b)
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
b
{boolean
}
.setTransition(opt_showTransition, opt_hideTransition)
Sets transition animation on showing and hiding the popup.
opt_showTransition
{goog.fx.Transition
=}
opt_hideTransition
{goog.fx.Transition
=}
.setType(type)
Specifies the type of popup to use.
type
{goog.ui.PopupBase.Type
}
.setVisible(visible)
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()
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
boolean
}
.showPopupElement()
[protected]Shows the popup element.