The goog.ui.Dialog.ButtonSet Class

goog.ui.Dialog.ButtonSet
> goog.structs.Map

goog.ui.Dialog.ButtonSet(opt_domHelper)

A button set defines the behaviour of a set of buttons that the dialog can show. Uses the {@link goog.structs.Map} interface.

opt_domHelper {goog.dom.DomHelper=}
Optional DOM helper; see {@link goog.ui.Component} for semantics.

The goog.ui.Dialog.ButtonSet.DefaultButtons Enum

The standard buttons (keys associated with captions). … more

.__iterator__(opt_keys)

Inherited from goog.structs.Map .

Returns an iterator that iterates over the values or the keys in the map. This throws an exception if the map was mutated since the iterator was created.

opt_keys {boolean=}
True to iterate over the keys. False to iterate over the values. The default value is false.
returns {!goog.iter.Iterator}
An iterator over the values or keys in the map.

.addAll(map)

Inherited from goog.structs.Map .

Adds multiple key-value pairs from another goog.structs.Map or Object.

map {Object}
Object containing the data to add.

.addButton(button, opt_isDefault, opt_isCancel)

Adds a button (an object with a key and caption) to this button set. Buttons will be displayed in the order they are added.

button {!{key: string, caption: string}}
The button key and caption.
opt_isDefault {boolean=}
Whether this button is the default button. Dialog will dispatch for this button if enter is pressed.
opt_isCancel {boolean=}
Whether this button has the same behavior as cancel. If escape is pressed this button will fire.
returns {!goog.ui.Dialog.ButtonSet}
The button set, to make it easy to chain "addButton" calls and build new ButtonSets.
@see
goog.ui.Dialog.DefaultButtons

.attachToElement(el)

Attaches the button set to an element, rendering it inside.

el {Element}
Container.

.clear()

Inherited from goog.structs.Map .

Removes all key-value pairs from the map.

.clone()

Inherited from goog.structs.Map .

Clones a map and returns a new map.

returns {!goog.structs.Map}
A new map with the same key-value pairs.

.containsKey(key)

Inherited from goog.structs.Map .

Whether the map contains the given key.

key {*}
The key to check for.
returns {boolean}
Whether the map contains the key.

.containsValue(val)

Inherited from goog.structs.Map .

Whether the map contains the given value. This is O(n).

val {*}
The value to check for.
returns {boolean}
Whether the map contains the value.

.createContinueSaveCancel()

Creates a new ButtonSet with 'Continue', 'Save', and 'Cancel' (default) buttons.

returns {!goog.ui.Dialog.ButtonSet}
The created ButtonSet.

.createOk()

Creates a new ButtonSet with a single 'OK' button, which is also set with cancel button semantics so that pressing escape will close the dialog.

returns {!goog.ui.Dialog.ButtonSet}
The created ButtonSet.

.createOkCancel()

Creates a new ButtonSet with 'OK' (default) and 'Cancel' buttons.

returns {!goog.ui.Dialog.ButtonSet}
The created ButtonSet.

.createYesNo()

Creates a new ButtonSet with 'Yes' (default) and 'No' buttons.

returns {!goog.ui.Dialog.ButtonSet}
The created ButtonSet.

.createYesNoCancel()

Creates a new ButtonSet with 'Yes', 'No' (default), and 'Cancel' buttons.

returns {!goog.ui.Dialog.ButtonSet}
The created ButtonSet.

.decorate(element)

Decorates the given element by adding any {@code button} elements found among its descendants to the button set. The first button found is assumed to be the default and will receive focus when the button set is rendered. If a button with a name of {@link goog.ui.Dialog.DefaultButtonKeys.CANCEL} is found, it is assumed to have "Cancel" semantics. TODO(attila): ButtonSet should be a goog.ui.Component. Really.

element {Element}
The element to decorate; should contain buttons.

.equals(otherMap, opt_equalityFn)

Inherited from goog.structs.Map .

Whether this map is equal to the argument map.

otherMap {goog.structs.Map}
The map against which to test equality.
opt_equalityFn {function(?, ?) : boolean=}
Optional equality function to test equality of values. If not specified, this will test whether the values contained in each map are identical objects.
returns {boolean}
Whether the maps are equal.

.get(key, opt_val)

Inherited from goog.structs.Map .

Returns the value for the given key. If the key is not found and the default value is not given this will return {@code undefined}.

key {*}
The key to get the value for.
opt_val {*=}
The value to return if no item is found for the given key, defaults to undefined.
returns {*}
The value for the given key.

.getAllButtons()

Returns all the HTML Button elements in the button set container.

returns {NodeList}
A live NodeList of the buttons.

.getButton(key)

Returns the HTML Button element.

key {string}
The button to return.
returns {Element}
The button, if found else null.

.getCancel()

Returns the cancel button.

returns {?string}
The cancel button.

.getCount()

Inherited from goog.structs.Map .

returns {number}
The number of key-value pairs in the map.

.getDefault()

Returns the default button.

returns {?string}
The default button.

.getDomHelper()

Returns the dom helper that is being used on this component.

returns {!goog.dom.DomHelper}
The dom helper used on this component. TODO(user): Remove after refactoring to goog.ui.Component.

.getElement()

Gets the component's element.

returns {Element}
The element for the component. TODO(user): Remove after refactoring to goog.ui.Component.

.getKeyIterator()

Inherited from goog.structs.Map .

Returns an iterator that iterates over the keys in the map. Removal of keys while iterating might have undesired side effects.

returns {!goog.iter.Iterator}
An iterator over the keys in the map.

.getKeys()

Inherited from goog.structs.Map .

Returns the keys of the map.

returns {!Array.<string>}
Array of string values.

.getValueIterator()

Inherited from goog.structs.Map .

Returns an iterator that iterates over the values in the map. Removal of keys while iterating might have undesired side effects.

returns {!goog.iter.Iterator}
An iterator over the values in the map.

.getValues()

Inherited from goog.structs.Map .

Returns the values of the map.

returns {!Array}
The values in the map.

.isEmpty()

Inherited from goog.structs.Map .

returns {boolean}
Whether the map is empty.

.remove(key)

Inherited from goog.structs.Map .

Removes a key-value pair based on the key. This is O(logN) amortized due to updating the keys array whenever the count becomes half the size of the keys in the keys array.

key {*}
The key to remove.
returns {boolean}
Whether object was removed.

.render()

Renders the button set inside its container element.

.set(key, caption, opt_isDefault, opt_isCancel)

Adds a button to the button set. Buttons will be displayed in the order they are added.

key {*}
Key used to identify the button in events.
caption {*}
A string caption or a DOM node that can be appended to a button element.
opt_isDefault {boolean=}
Whether this button is the default button, Dialog will dispatch for this button if enter is pressed.
opt_isCancel {boolean=}
Whether this button has the same behaviour as cancel. If escape is pressed this button will fire.
returns {!goog.ui.Dialog.ButtonSet}
The button set, to make it easy to chain "set" calls and build new ButtonSets.

.setAllButtonsEnabled(enabled)

Enables or disables all of the buttons in this set.

enabled {boolean}
True to enable; false to disable.

.setButtonEnabled(key, enabled)

Enables or disables a button in this set by key. If the button is not found, does nothing.

key {string}
The button to enable or disable.
enabled {boolean}
True to enable; false to disable.

.setCancel(key)

Sets the cancel button.

key {?string}
The cancel button.

.setDefault(key)

Sets the default button.

key {?string}
The default button.

.toObject()

Inherited from goog.structs.Map .

returns {!Object}
Object representation of the map.

.transpose()

Inherited from goog.structs.Map .

Returns a new map in which all the keys and values are interchanged (keys become values and values become keys). If multiple keys map to the same value, the chosen transposed value is implementation-dependent. It acts very similarly to {goog.object.transpose(Object)}.

returns {!goog.structs.Map}
The transposed map.