Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/ui/option.js
4062 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview A menu item class that supports selection state.
9
*/
10
11
goog.provide('goog.ui.Option');
12
13
goog.require('goog.ui.Component');
14
goog.require('goog.ui.MenuItem');
15
goog.require('goog.ui.registry');
16
goog.requireType('goog.dom.DomHelper');
17
goog.requireType('goog.events.Event');
18
goog.requireType('goog.ui.ControlContent');
19
20
21
22
/**
23
* Class representing a menu option. This is just a convenience class that
24
* extends {@link goog.ui.MenuItem} by making it selectable.
25
*
26
* @param {goog.ui.ControlContent} content Text caption or DOM structure to
27
* display as the content of the item (use to add icons or styling to
28
* menus).
29
* @param {*=} opt_model Data/model associated with the menu item.
30
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper used for
31
* document interactions.
32
* @constructor
33
* @extends {goog.ui.MenuItem}
34
*/
35
goog.ui.Option = function(content, opt_model, opt_domHelper) {
36
'use strict';
37
goog.ui.MenuItem.call(this, content, opt_model, opt_domHelper);
38
this.setSelectable(true);
39
};
40
goog.inherits(goog.ui.Option, goog.ui.MenuItem);
41
42
43
/**
44
* Performs the appropriate action when the option is activated by the user.
45
* Overrides the superclass implementation by not changing the selection state
46
* of the option and not dispatching any SELECTED events, for backwards
47
* compatibility with existing uses of this class.
48
* @param {goog.events.Event} e Mouse or key event that triggered the action.
49
* @return {boolean} True if the action was allowed to proceed, false otherwise.
50
* @override
51
*/
52
goog.ui.Option.prototype.performActionInternal = function(e) {
53
'use strict';
54
return this.dispatchEvent(goog.ui.Component.EventType.ACTION);
55
};
56
57
58
// Register a decorator factory function for goog.ui.Options.
59
goog.ui.registry.setDecoratorByClassName(
60
goog.getCssName('goog-option'), function() {
61
'use strict';
62
// Option defaults to using MenuItemRenderer.
63
return new goog.ui.Option(null);
64
});
65
66