goog.ui.PopupBase
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
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.
new PopupBase( opt_element, opt_type )
Parameters |
|
---|
Instance Methods
this.addAutoHidePartner( partner ) → void
void
Mouse events that occur within an autoHide partner will not hide a popup set to autoHide.
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.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.getAutoHide() → boolean
boolean
Returns whether the Popup dismisses itself when the user clicks outside of it.
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.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElement() → (Element|null)
(Element|null)
Returns the dom element that should be used for the popup.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEnableCrossIframeDismissal() → boolean
boolean
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
.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHideOnEscape() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastHideTime() → number
number
Returns the time when the popup was last hidden.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastShowTime() → number
number
Returns the time when the popup was last shown.
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.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.getType() → goog.ui.PopupBase.Type
goog.ui.PopupBase.Type
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.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); }
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isVisible() → boolean
boolean
Returns whether the popup is currently visible.
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.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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.onBeforeShow() → boolean
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.
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.
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.
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. Should be overriden by subclases.
this.setAutoHide( autoHide ) → void
void
Sets whether the Popup dismisses itself when the user clicks outside of it.
Parameters |
|
---|
this.setAutoHideRegion( element ) → void
void
Sets the region inside which the Popup dismisses itself when the user clicks.
Parameters |
|
---|
this.setElement( elt ) → void
void
Specifies the dom element that should be used for the popup.
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
Parameters |
|
---|
this.setHideOnEscape( hideOnEscape ) → void
void
Sets whether the Popup dismisses itself on the escape key.
Parameters |
|
---|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setShouldHideAsync( b ) → void
void
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
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.setTransition( opt_showTransition, opt_hideTransition ) → void
void
Sets transition animation on showing and hiding the popup.
Parameters |
|
---|
this.setType( type ) → void
void
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.
Parameters |
|
---|
this.shouldHideAsync() → boolean
boolean
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.showPopupElement() → void
void
Shows the popup element.
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.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Static Properties
PopupBase.DEBOUNCE_DELAY_MS → number
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.