ui.AttachableMenu Extends goog.ui.MenuBase
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.

Inheritance

Constructor

goog.ui.AttachableMenu(opt_element)

Parameters

opt_element : Element=
A DOM element for the popup.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
getAncestorMenuItem_(elt) Element
Returns the menu-item scoping the specified element, or null if there is none.
Arguments:
elt : Element | undefined
The element to find a menu item ancestor of.
Returns: Element  The menu-item scoping the specified element, or null if there is none.
code »
getItemClassName() string
Sets the class name to use for menu items
Returns: string  The class name to use for items.
code »
getNextPrevItem(prev) Element
Returns the next or previous item. Used for up/down arrows.
Arguments:
prev : boolean
True to go to the previous element instead of next.
Returns: Element  The next or previous element.
code »
getSelectedItem() Element
Returns the selected item
Returns: Element  The item selected or null if no item is selected.
code »
getSelectedItemClassName() string
Sets the class name to use for selected menu items todo(user) - reevaluate if we can simulate pseudo classes in IE
Returns: string  The class name to use for selected items.
code »
isMenuItem_(elt) boolean
Returns whether the specified element is a menu item.
Arguments:
elt : Element
The element to find a menu item ancestor of.
Returns: boolean  Whether the specified element is a menu item.
code »
onItemSelected_(opt_item)
Dispatch an ITEM_ACTION event when an item is selected
Arguments:
opt_item : Object=
Item selected.
code »
onKeyDown(e)
Key down handler for the menu.
Arguments:
e : goog.events.KeyEvent
The event object.
code »
onMouseDown(e)
Mouse down handler for the menu. Prevents default to avoid text selection.
Arguments:
e : !goog.events.Event
The event object.
code »
onMouseOut(e)
Mouse out handler for the menu.
Arguments:
e : goog.events.Event
The event object.
code »
onMouseOver(e)
Mouse over handler for the menu.
Arguments:
e : goog.events.Event
The event object.
code »
onMouseUp(e)
Mouse up handler for the menu.
Arguments:
e : goog.events.Event
The event object.
code »
onShow_()
Called after the menu is shown.
code »
selectByName_(prefixopt_directionopt_skip)
Find an item that has the given prefix and select it.
Arguments:
prefix : string
The entered prefix, so far.
opt_direction : number=
1 to search forward from the selection (default), -1 to search backward (e.g. to go to the previous match).
opt_skip : boolean=
True if should skip the current selection, unless no other item has the given prefix.
code »
setItemClassName(name)
Sets the class name to use for menu items
Arguments:
name : string
The class name to use for items.
code »
setSelectedItem()
No description.
code »
setSelectedItemClassName(name)
Sets the class name to use for selected menu items todo(user) - reevaluate if we can simulate pseudo classes in IE
Arguments:
name : string
The class name to use for selected items.
code »
showPopupElement()
No description.
code »
disposeInternal()
No description.
code »
getSelectedItem() Object
Returns the selected item
Returns: Object  The item selected or null if no item is selected.
code »
onHide_(opt_target)
Called after the menu is hidden. Derived classes can override to hook this event but should make sure to call the parent class method.
Arguments:
opt_target : Object=
Target of the event causing the hide.
code »
onKeyDown(e)
Key down handler for the menu. Derived classes should override.
Arguments:
e : goog.events.KeyEvent
The event object.
code »
onMouseDown(e)
Mouse down handler for the menu. Derived classes should override.
Arguments:
e : !goog.events.Event
The event object.
code »
onMouseOut(e)
Mouse out handler for the menu. Derived classes should override.
Arguments:
e : goog.events.Event
The event object.
code »
onMouseOver(e)
Mouse over handler for the menu. Derived classes should override.
Arguments:
e : goog.events.Event
The event object.
code »
onMouseUp(e)
Mouse up handler for the menu. Derived classes should override.
Arguments:
e : goog.events.Event
The event object.
code »
onShow_()
Called after the menu is shown. Derived classes can override to hook this event but should make sure to call the parent class method.
code »
setSelectedItem(item)
Sets the selected item
Arguments:
item : Object
The item to select. The type of this item is specific to the menu class.
code »
Defined in goog.ui.Popup
getMargin() ?goog.math.Box
Returns the margin to place around the popup.
Returns: ?goog.math.Box  The margin.
code »
getPinnedCorner() goog.positioning.Corner
Returns the corner of the popup to used in the positioning algorithm.
Returns: goog.positioning.Corner  The popup corner used for positioning.
code »
No description.
Returns: goog.positioning.AbstractPosition  The position helper object associated with the popup.
code »
reposition()
Repositions the popup according to the current state.
code »
setMargin(arg1opt_arg2opt_arg3opt_arg4)
Sets the margin to place around the popup.
Arguments:
arg1 : goog.math.Box | number | null
Top value or Box.
opt_arg2 : number=
Right value.
opt_arg3 : number=
Bottom value.
opt_arg4 : number=
Left value.
code »
setPinnedCorner(corner)
Sets the corner of the popup to used in the positioning algorithm.
Arguments:
corner : goog.positioning.Corner
The popup corner used for positioning.
code »
setPosition(position)
Sets the position helper object associated with the popup.
Arguments:
position : goog.positioning.AbstractPosition
A position helper object.
code »
addAutoHidePartner(partner)
Mouse events that occur within an autoHide partner will not hide a popup set to autoHide.
Arguments:
partner : !Element
The auto hide partner element.
code »
continueHidingPopup_(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.
Arguments:
opt_target : Object=
Target of the event causing the hide.
code »
disposeInternal()
No description.
code »
ensureNotVisible_()
Helper to throw exception if the popup is showing.
code »
getAutoHide() boolean
Returns whether the Popup dismisses itself when the user clicks outside of it.
Returns: boolean  Whether the Popup autohides on an external click.
code »
getAutoHideRegion() Element
Returns the region inside which the Popup dismisses itself when the user clicks, or null if it's the entire document.
Returns: Element  The DOM element for autohide, or null if it hasn't been set.
code »
getElement() Element
Returns the dom element that should be used for the popup.
Returns: Element  The popup element.
code »
getEnableCrossIframeDismissal() boolean
No description.
Returns: boolean  Whether cross iframe dismissal is enabled.
code »
getHandler() goog.events.EventHandler.<T>
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_.
Returns: goog.events.EventHandler.<T>  Event handler for this popup.
code »
getHideOnEscape() boolean
No description.
Returns: boolean  Whether the Popup autohides on the escape key.
code »
getLastHideTime() number
Returns the time when the popup was last hidden.
Returns: number  time in ms since epoch when the popup was last hidden, or -1 if the popup was never hidden or is currently showing.
code »
getLastShowTime() number
Returns the time when the popup was last shown.
Returns: number  time in ms since epoch when the popup was last shown, or -1 if the popup was never shown.
code »
getType() goog.ui.PopupBase.Type
No description.
Returns: goog.ui.PopupBase.Type  The type of popup this is.
code »
hidePopupElement()
Hides the popup element.
code »
hide_(opt_target) boolean
Hides the popup. This call is idempotent.
Arguments:
opt_target : Object=
Target of the event causing the hide.
Returns: boolean  Whether the popup was hidden and not cancelled.
code »
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); }
Returns: boolean  Whether the popup is currently visible or was visible within about 150 ms ago.
code »
isOrWithinAutoHidePartner_(element) boolean
No description.
Arguments:
element : Node
The element to inspect.
Returns: boolean  Returns true if the given element is one of the auto hide partners or is a child of an auto hide partner.
code »
isVisible() boolean
Returns whether the popup is currently visible.
Returns: boolean  whether the popup is currently visible.
code »
isWithinAutoHideRegion_(element) boolean
No description.
Arguments:
element : Node
The element to inspect.
Returns: boolean  Returns true if the element is contained within the autohide region. If unset, the autohide region is the entire entire document.
code »
moveOffscreen_()
Hides the popup by moving it offscreen.
code »
onBeforeHide_(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.
Arguments:
opt_target : Object=
Target of the event causing the hide.
Returns: boolean  If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.
code »
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.
Returns: boolean  If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.
code »
onDocumentBlur_(e)
Deactivate handler(IE) and blur handler (other browsers) for document. Used to hide the popup for auto-hide mode.
Arguments:
e : goog.events.BrowserEvent
The event object.
code »
onDocumentKeyDown_(e)
Handles key-downs on the document to handle the escape key.
Arguments:
e : goog.events.BrowserEvent
The event object.
code »
onDocumentMouseDown_(e)
Mouse down handler for the document on capture phase. Used to hide the popup for auto-hide mode.
Arguments:
e : goog.events.BrowserEvent
The event object.
code »
onHide_(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.
Arguments:
opt_target : Object=
Target of the event causing the hide.
code »
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.
code »
removeAutoHidePartner(partner)
Removes a previously registered auto hide partner.
Arguments:
partner : !Element
The auto hide partner element.
code »
reposition()
Repositions the popup according to the current state. Should be overriden by subclases.
code »
setAutoHide(autoHide)
Sets whether the Popup dismisses itself when the user clicks outside of it.
Arguments:
autoHide : boolean
Whether to autohide on an external click.
code »
setAutoHideRegion(element)
Sets the region inside which the Popup dismisses itself when the user clicks.
Arguments:
element : Element
The DOM element for autohide.
code »
setElement(elt)
Specifies the dom element that should be used for the popup.
Arguments:
elt : Element
A DOM element for the popup.
code »
setEnableCrossIframeDismissal(enable)
Sets whether clicks in other iframes should dismiss this popup. In some cases it should be disabled, because it can cause spurious
Arguments:
enable : boolean
Whether to enable cross iframe dismissal.
code »
setHideOnEscape(hideOnEscape)
Sets whether the Popup dismisses itself on the escape key.
Arguments:
hideOnEscape : boolean
Whether to autohide on the escape key.
code »
setShouldHideAsync(b)
Sets whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Arguments:
b : boolean
Whether to hide async.
code »
setTransition(opt_showTransitionopt_hideTransition)
Sets transition animation on showing and hiding the popup.
Arguments:
opt_showTransition : goog.fx.Transition=
Transition to play on showing the popup.
opt_hideTransition : goog.fx.Transition=
Transition to play on hiding the popup.
code »
setType(type)
Specifies the type of popup to use.
Arguments:
type : goog.ui.PopupBase.Type
Type of popup.
code »
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.
Arguments:
visible : boolean
Desired visibility state.
code »
shouldDebounce_() boolean
No description.
Returns: boolean  Whether the time since last show is less than the debounce delay.
code »
shouldHideAsync() boolean
Returns whether the popup should hide itself asynchronously using a timeout instead of synchronously.
Returns: boolean  Whether to hide async.
code »
showPopupElement()
Shows the popup element.
code »
show_()
Does the work to show the popup.
code »
addEventListener(typeopt_captureopt_handlerScope)
Use #listen instead, when possible. Otherwise, use goog.events.listen if you are passing Object (instead of Function) as handler. 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.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
assertInitialized_()
Asserts that the event target instance is initialized properly.
code »
dispatchEvent()
No description.
code »
disposeInternal()
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.
code »
fireListeners()
No description.
code »
getListener()
No description.
code »
getListeners()
No description.
code »
getParentEventTarget() goog.events.EventTarget
Returns the parent of this event target to use for bubbling.
Returns: goog.events.EventTarget  The parent EventTarget or null if there is no parent.
code »
hasListener()
No description.
code »
listen()
No description.
code »
listenOnce()
No description.
code »
removeAllListeners()
No description.
code »
removeEventListener(typeopt_captureopt_handlerScope)
Use #unlisten instead, when possible. Otherwise, use goog.events.unlisten if you are passing Object (instead of Function) as handler. 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.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for capture/bubble mechanism.
Arguments:
parent : goog.events.EventTarget
Parent listenable (null if none).
code »
setTargetForTesting(target)
Sets the target to be used for event.target when firing event. Mainly used for testing. For example, see goog.testing.events.mixinListenable.
Arguments:
target : !Object
The target.
code »
unlisten()
No description.
code »
unlistenByKey()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

constructor :
No description.
Code »
itemClassName_ :
Class name to append to a menu item's class when it's selected
Code »
lastKeyDown_ :
Keep track of when the last key was pressed so that a keydown-scroll doesn't trigger a mouseover event
Code »
selectedElement_ :
The currently selected element (mouse was moved over it or keyboard arrows)
Code »
selectedItemClassName_ :
Class name to append to a menu item's class when it's selected
Code »
constructor :
No description.
Code »
eventHandler_ : goog.events.EventHandler
Event handler for simplifiying adding/removing listeners.
Code »
keyHandler_ : goog.events.KeyHandler
KeyHandler to cope with the vagaries of cross-browser key events.
Code »
Defined in goog.ui.Popup
constructor :
No description.
Code »
margin_ : goog.math.Box
Margin for the popup used in positioning algorithms.
Code »
popupCorner_ :
Corner of the popup to used in the positioning algorithm.
Code »
Positioning helper object.
Code »
autoHidePartners_ :
Mouse events without auto hide partner elements will not dismiss the popup.
Code »
autoHideRegion_ :
Clicks outside the popup but inside this element will cause the popup to hide if autoHide_ is true. If this is null, then the entire document is used. For example, you can use a body-size div so that clicks on the browser scrollbar do not dismiss the popup.
Code »
autoHide_ :
Whether the Popup dismisses itself it the user clicks outside of it or the popup loses focus
Code »
constructor :
No description.
Code »
element_ :
The popup dom element that this Popup wraps.
Code »
enableCrossIframeDismissal_ :
Whether to enable cross-iframe dismissal.
Code »
An event handler to manage the events easily
Code »
hideOnEscape_ :
Whether to hide when the escape key is pressed.
Code »
hideTransition_ : goog.fx.Transition
Transition to play on hiding the popup.
Code »
isVisible_ :
Whether the popup is currently being shown.
Code »
lastHideTime_ :
The time when the popup was last hidden.
Code »
lastShowTime_ :
The time when the popup was last shown.
Code »
shouldHideAsync_ :
Whether the popup should hide itself asynchrously. This was added because there are cases where hiding the element in mouse down handler in IE can cause textinputs to get into a bad state if the element that had focus is hidden.
Code »
showTransition_ : goog.fx.Transition
Transition to play on showing the popup.
Code »
type_ :
The type of popup
Code »
actualEventTarget_ : goog.events.EventTarget
The object to use for event.target. Useful when mixing in an EventTarget to another object.
Code »
constructor :
No description.
Code »
eventTargetListeners_ : goog.events.ListenerMap
Maps of event type to an array of listeners.
Code »
parentEventTarget_ : goog.events.EventTarget
Parent event target, used during event bubbling. TODO(user): Change this to goog.events.Listenable. This currently breaks people who expect getParentEventTarget to return goog.events.EventTarget.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.ui.AttachableMenu.superClass_ :
No description.
Code »

Package ui

Package Reference