@@ -32,6 +32,7 @@ import '../../theme/components/button/button.css';
32
32
* document.body.append( view.element );
33
33
*
34
34
* @extends module:ui/view~View
35
+ * @implements module:ui/button/button~Button
35
36
*/
36
37
export default class ButtonView extends View {
37
38
/**
@@ -42,118 +43,19 @@ export default class ButtonView extends View {
42
43
43
44
const bind = this . bindTemplate ;
44
45
45
- /**
46
- * The label of the button view visible to the user when {@link #withText} is `true`.
47
- * It can also be used to create a {@link #tooltip}.
48
- *
49
- * @observable
50
- * @member {String} #label
51
- */
52
- this . set ( 'label' ) ;
53
-
54
- /**
55
- * (Optional) The keystroke associated with the button, i.e. <kbd>CTRL+B</kbd>,
56
- * in the string format compatible with {@link module:utils/keyboard}.
57
- *
58
- * @observable
59
- * @member {Boolean} #keystroke
60
- */
46
+ // Implement the Button interface.
47
+ this . set ( 'icon' ) ;
48
+ this . set ( 'isEnabled' , true ) ;
49
+ this . set ( 'isOn' , false ) ;
50
+ this . set ( 'isVisible' , true ) ;
61
51
this . set ( 'keystroke' ) ;
62
-
63
- /**
64
- * (Optional) Tooltip of the button, i.e. displayed when hovering the button with the mouse cursor.
65
- *
66
- * * If defined as a `Boolean` (e.g. `true`), then combination of `label` and `keystroke` will be set as a tooltip.
67
- * * If defined as a `String`, tooltip will equal the exact text of that `String`.
68
- * * If defined as a `Function`, `label` and `keystroke` will be passed to that function, which is to return
69
- * a string with the tooltip text.
70
- *
71
- * const view = new ButtonView( locale );
72
- * view.tooltip = ( label, keystroke ) => `A tooltip for ${ label } and ${ keystroke }.`
73
- *
74
- * @observable
75
- * @default false
76
- * @member {Boolean|String|Function} #tooltip
77
- */
52
+ this . set ( 'label' ) ;
53
+ this . set ( 'tabindex' , - 1 ) ;
78
54
this . set ( 'tooltip' ) ;
79
-
80
- /**
81
- * (Optional) The position of the tooltip. See {@link module:ui/tooltip/tooltipview~TooltipView#position}
82
- * to learn more about the available position values.
83
- *
84
- * **Note:** It makes sense only when the {@link #tooltip `tooltip` attribute} is defined.
85
- *
86
- * @observable
87
- * @default 's'
88
- * @member {'s'|'n'} #position
89
- */
90
55
this . set ( 'tooltipPosition' , 's' ) ;
91
-
92
- /**
93
- * The HTML type of the button. Default `button`.
94
- *
95
- * @observable
96
- * @member {'button'|'submit'|'reset'|'menu'} #type
97
- */
98
56
this . set ( 'type' , 'button' ) ;
99
-
100
- /**
101
- * Controls whether the button view is "on". It makes sense when a feature it represents
102
- * is currently active, e.g. a bold button is "on" when the selection is in the bold text.
103
- *
104
- * To disable the button, use {@link #isEnabled} instead.
105
- *
106
- * @observable
107
- * @member {Boolean} #isOn
108
- */
109
- this . set ( 'isOn' , false ) ;
110
-
111
- /**
112
- * Controls whether the button view is enabled, i.e. it can be clicked and execute an action.
113
- *
114
- * To change the "on" state of the button, use {@link #isOn} instead.
115
- *
116
- * @observable
117
- * @member {Boolean} #isEnabled
118
- */
119
- this . set ( 'isEnabled' , true ) ;
120
-
121
- /**
122
- * Controls whether the button view is visible. Visible by default, buttons are hidden
123
- * using a CSS class.
124
- *
125
- * @observable
126
- * @member {Boolean} #isVisible
127
- */
128
- this . set ( 'isVisible' , true ) ;
129
-
130
- /**
131
- * (Optional) Controls whether the label of the button is hidden (e.g. an icon–only button).
132
- *
133
- * @observable
134
- * @member {Boolean} #withText
135
- */
136
57
this . set ( 'withText' , false ) ;
137
58
138
- /**
139
- * (Optional) An XML {@link module:ui/icon/iconview~IconView#content content} of the icon.
140
- * When defined, an {@link #iconView} will be added to the button.
141
- *
142
- * @observable
143
- * @member {String} #icon
144
- */
145
- this . set ( 'icon' ) ;
146
-
147
- /**
148
- * (Optional) Controls the `tabindex` HTML attribute of the button. By default, the button is focusable
149
- * but does not included in the <kbd>Tab</kbd> order.
150
- *
151
- * @observable
152
- * @default -1
153
- * @member {String} #tabindex
154
- */
155
- this . set ( 'tabindex' , - 1 ) ;
156
-
157
59
/**
158
60
* Collection of the child views inside of the button {@link #element}.
159
61
*
@@ -178,6 +80,13 @@ export default class ButtonView extends View {
178
80
*/
179
81
this . labelView = this . _createLabelView ( ) ;
180
82
83
+ /**
84
+ * (Optional) The icon view of the button. Only present when the {@link #icon icon attribute} is defined.
85
+ *
86
+ * @readonly
87
+ * @member {module:ui/icon/iconview~IconView} #iconView
88
+ */
89
+
181
90
/**
182
91
* Tooltip of the button bound to the template.
183
92
*
@@ -194,13 +103,6 @@ export default class ButtonView extends View {
194
103
this . _getTooltipString . bind ( this )
195
104
) ;
196
105
197
- /**
198
- * (Optional) The icon view of the button. Only present when the {@link #icon icon attribute} is defined.
199
- *
200
- * @readonly
201
- * @member {module:ui/icon/iconview~IconView} #iconView
202
- */
203
-
204
106
this . setTemplate ( {
205
107
tag : 'button' ,
206
108
@@ -236,13 +138,6 @@ export default class ButtonView extends View {
236
138
} )
237
139
}
238
140
} ) ;
239
-
240
- /**
241
- * Fired when the button view is clicked. It won't be fired when the button {@link #isEnabled}
242
- * is `false`.
243
- *
244
- * @event execute
245
- */
246
141
}
247
142
248
143
/**
0 commit comments