goog.ui.AttachableMenu
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
warning Deprecated | Use goog.ui.PopupMenu. |
---|
An implementation of a menu that can attach itself to DOM element that are annotated appropriately.
The following attributes are used by the AttachableMenu
menu-item - Should be set on DOM elements that function as items in the menu that can be selected. classNameSelected - A class that will be added to the element's class names when the item is selected via keyboard or mouse.
new AttachableMenu( opt_element )
Parameters |
|
---|
Instance Methods
this.addAutoHidePartner( partner ) → void
void
Mouse events that occur within an autoHide partner will not hide a popup set to autoHide.
Defined by | |||||
---|---|---|---|---|---|
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.
Defined by | |||
---|---|---|---|
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.
Defined by | |||
---|---|---|---|
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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEnableCrossIframeDismissal() → boolean
boolean
Defined by | |||
---|---|---|---|
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
.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHideOnEscape() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getItemClassName() → string
string
Sets the class name to use for menu items
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastHideTime() → number
number
Returns the time when the popup was last hidden.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getLastShowTime() → number
number
Returns the time when the popup was last shown.
Defined by | |||
---|---|---|---|
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.getMargin() → (goog.math.Box|null)
(goog.math.Box|null)
Returns the margin to place around the popup.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getNextPrevItem( prev ) → (Element|null)
(Element|null)
Returns the next or previous item. Used for up/down arrows.
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.getPinnedCorner() → goog.positioning.Corner
goog.positioning.Corner
Returns the corner of the popup to used in the positioning algorithm.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getPosition() → (goog.positioning.AbstractPosition|null)
(goog.positioning.AbstractPosition|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getSelectedItem() → (Element|null)
(Element|null)
Returns the selected item
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getSelectedItemClassName() → string
string
Sets the class name to use for selected menu items todo(jonp) - reevaluate if we can simulate pseudo classes in IE
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getType() → goog.ui.PopupBase.Type
goog.ui.PopupBase.Type
Defined by | |||
---|---|---|---|
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); }
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isVisible() → boolean
boolean
Returns whether the popup is currently visible.
Defined by | |||
---|---|---|---|
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.
Defined by | |||||
---|---|---|---|---|---|
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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.onHide( opt_target ) → void
void
Called after the menu is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.onKeyDown( e ) → void
void
Key down handler for the menu.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onMouseDown( e ) → void
void
Mouse down handler for the menu. Prevents default to avoid text selection.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onMouseOut( e ) → void
void
Mouse out handler for the menu.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onMouseOver( e ) → void
void
Mouse over handler for the menu.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onMouseUp( e ) → void
void
Mouse up handler for the menu.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.onShow() → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
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.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.setAutoHide( autoHide ) → void
void
Sets whether the Popup dismisses itself when the user clicks outside of it.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAutoHideRegion( element ) → void
void
Sets the region inside which the Popup dismisses itself when the user clicks.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setElement( elt ) → void
void
Specifies the dom element that should be used for the popup.
Defined by | |||||
---|---|---|---|---|---|
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
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHideOnEscape( hideOnEscape ) → void
void
Sets whether the Popup dismisses itself on the escape key.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setItemClassName( name ) → void
void
Sets the class name to use for menu items
Parameters |
|
---|
this.setMargin( arg1, opt_arg2, opt_arg3, opt_arg4 ) → void
void
Sets the margin to place around the popup.
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPinnedCorner( corner ) → void
void
Sets the corner of the popup to used in the positioning algorithm.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPosition( position ) → void
void
Sets the position helper object associated with the popup.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setSelectedItem( item ) → void
void
Sets the selected item
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.setSelectedItemClassName( name ) → void
void
Sets the class name to use for selected menu items todo(jonp) - reevaluate if we can simulate pseudo classes in IE
Parameters |
|
---|
this.setShouldHideAsync( b ) → void
void
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Defined by | |||||
---|---|---|---|---|---|
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.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setType( type ) → void
void
Specifies the type of popup to use.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.shouldHideAsync() → boolean
boolean
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.showPopupElement() → void
void
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.