@ckeditor/ckeditor5-ui 35.2.1 → 35.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +31 -23
- package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
- package/src/bindings/clickoutsidehandler.js +15 -21
- package/src/bindings/injectcsstransitiondisabler.js +16 -20
- package/src/bindings/preventdefault.js +6 -8
- package/src/bindings/submithandler.js +5 -7
- package/src/button/button.js +5 -0
- package/src/button/buttonview.js +220 -259
- package/src/button/switchbuttonview.js +56 -71
- package/src/colorgrid/colorgridview.js +135 -197
- package/src/colorgrid/colortileview.js +37 -47
- package/src/colorgrid/utils.js +57 -66
- package/src/componentfactory.js +79 -93
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.js +44 -57
- package/src/dropdown/button/splitbuttonview.js +159 -207
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.js +101 -112
- package/src/dropdown/dropdownview.js +396 -438
- package/src/dropdown/utils.js +164 -213
- package/src/editableui/editableuiview.js +125 -141
- package/src/editableui/inline/inlineeditableuiview.js +44 -54
- package/src/editorui/bodycollection.js +61 -75
- package/src/editorui/boxed/boxededitoruiview.js +91 -104
- package/src/editorui/editoruiview.js +30 -39
- package/src/focuscycler.js +214 -245
- package/src/formheader/formheaderview.js +58 -70
- package/src/icon/iconview.js +145 -111
- package/src/iframe/iframeview.js +37 -49
- package/src/index.js +0 -17
- package/src/input/inputview.js +170 -198
- package/src/inputnumber/inputnumberview.js +48 -56
- package/src/inputtext/inputtextview.js +14 -18
- package/src/label/labelview.js +44 -53
- package/src/labeledfield/labeledfieldview.js +212 -235
- package/src/labeledfield/utils.js +39 -57
- package/src/labeledinput/labeledinputview.js +190 -221
- package/src/list/listitemview.js +40 -50
- package/src/list/listseparatorview.js +15 -19
- package/src/list/listview.js +94 -115
- package/src/model.js +19 -25
- package/src/notification/notification.js +151 -202
- package/src/panel/balloon/balloonpanelview.js +535 -628
- package/src/panel/balloon/contextualballoon.js +611 -732
- package/src/panel/sticky/stickypanelview.js +238 -270
- package/src/template.js +1049 -1479
- package/src/toolbar/balloon/balloontoolbar.js +337 -424
- package/src/toolbar/block/blockbuttonview.js +32 -42
- package/src/toolbar/block/blocktoolbar.js +375 -477
- package/src/toolbar/normalizetoolbarconfig.js +17 -21
- package/src/toolbar/toolbarlinebreakview.js +15 -19
- package/src/toolbar/toolbarseparatorview.js +15 -19
- package/src/toolbar/toolbarview.js +866 -1053
- package/src/tooltipmanager.js +324 -353
- package/src/view.js +389 -430
- package/src/viewcollection.js +147 -178
- package/src/button/button.jsdoc +0 -165
- package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
- package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
package/src/button/buttonview.js
CHANGED
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module ui/button/buttonview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import IconView from '../icon/iconview';
|
|
12
|
-
|
|
13
10
|
import uid from '@ckeditor/ckeditor5-utils/src/uid';
|
|
14
11
|
import { getEnvKeystrokeText } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
15
12
|
import env from '@ckeditor/ckeditor5-utils/src/env';
|
|
16
|
-
|
|
17
13
|
import '../../theme/components/button/button.css';
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* The button view class.
|
|
21
16
|
*
|
|
@@ -36,258 +31,224 @@ import '../../theme/components/button/button.css';
|
|
|
36
31
|
* @implements module:ui/button/button~Button
|
|
37
32
|
*/
|
|
38
33
|
export default class ButtonView extends View {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return keystrokeView;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Gets the text for the tooltip from the combination of
|
|
264
|
-
* {@link #tooltip}, {@link #label} and {@link #keystroke} attributes.
|
|
265
|
-
*
|
|
266
|
-
* @private
|
|
267
|
-
* @see #tooltip
|
|
268
|
-
* @see #_tooltipString
|
|
269
|
-
* @param {Boolean|String|Function} tooltip Button tooltip.
|
|
270
|
-
* @param {String} label Button label.
|
|
271
|
-
* @param {String} keystroke Button keystroke.
|
|
272
|
-
* @returns {String}
|
|
273
|
-
*/
|
|
274
|
-
_getTooltipString( tooltip, label, keystroke ) {
|
|
275
|
-
if ( tooltip ) {
|
|
276
|
-
if ( typeof tooltip == 'string' ) {
|
|
277
|
-
return tooltip;
|
|
278
|
-
} else {
|
|
279
|
-
if ( keystroke ) {
|
|
280
|
-
keystroke = getEnvKeystrokeText( keystroke );
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if ( tooltip instanceof Function ) {
|
|
284
|
-
return tooltip( label, keystroke );
|
|
285
|
-
} else {
|
|
286
|
-
return `${ label }${ keystroke ? ` (${ keystroke })` : '' }`;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return '';
|
|
292
|
-
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
constructor(locale) {
|
|
38
|
+
super(locale);
|
|
39
|
+
const bind = this.bindTemplate;
|
|
40
|
+
const ariaLabelUid = uid();
|
|
41
|
+
// Implement the Button interface.
|
|
42
|
+
this.set('class', undefined);
|
|
43
|
+
this.set('labelStyle', undefined);
|
|
44
|
+
this.set('icon', undefined);
|
|
45
|
+
this.set('isEnabled', true);
|
|
46
|
+
this.set('isOn', false);
|
|
47
|
+
this.set('isVisible', true);
|
|
48
|
+
this.set('isToggleable', false);
|
|
49
|
+
this.set('keystroke', undefined);
|
|
50
|
+
this.set('label', undefined);
|
|
51
|
+
this.set('tabindex', -1);
|
|
52
|
+
this.set('tooltip', false);
|
|
53
|
+
this.set('tooltipPosition', 's');
|
|
54
|
+
this.set('type', 'button');
|
|
55
|
+
this.set('withText', false);
|
|
56
|
+
this.set('withKeystroke', false);
|
|
57
|
+
/**
|
|
58
|
+
* Collection of the child views inside of the button {@link #element}.
|
|
59
|
+
*
|
|
60
|
+
* @readonly
|
|
61
|
+
* @member {module:ui/viewcollection~ViewCollection}
|
|
62
|
+
*/
|
|
63
|
+
this.children = this.createCollection();
|
|
64
|
+
/**
|
|
65
|
+
* Label of the button view. It is configurable using the {@link #label label attribute}.
|
|
66
|
+
*
|
|
67
|
+
* @readonly
|
|
68
|
+
* @member {module:ui/view~View} #labelView
|
|
69
|
+
*/
|
|
70
|
+
this.labelView = this._createLabelView(ariaLabelUid);
|
|
71
|
+
/**
|
|
72
|
+
* The icon view of the button. Will be added to {@link #children} when the
|
|
73
|
+
* {@link #icon icon attribute} is defined.
|
|
74
|
+
*
|
|
75
|
+
* @readonly
|
|
76
|
+
* @member {module:ui/icon/iconview~IconView} #iconView
|
|
77
|
+
*/
|
|
78
|
+
this.iconView = new IconView();
|
|
79
|
+
this.iconView.extendTemplate({
|
|
80
|
+
attributes: {
|
|
81
|
+
class: 'ck-button__icon'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* A view displaying the keystroke of the button next to the {@link #labelView label}.
|
|
86
|
+
* Added to {@link #children} when the {@link #withKeystroke `withKeystroke` attribute}
|
|
87
|
+
* is defined.
|
|
88
|
+
*
|
|
89
|
+
* @readonly
|
|
90
|
+
* @member {module:ui/view/view~View} #keystrokeView
|
|
91
|
+
*/
|
|
92
|
+
this.keystrokeView = this._createKeystrokeView();
|
|
93
|
+
/**
|
|
94
|
+
* Tooltip of the button bound to the template.
|
|
95
|
+
*
|
|
96
|
+
* @see #tooltip
|
|
97
|
+
* @see #_getTooltipString
|
|
98
|
+
* @private
|
|
99
|
+
* @observable
|
|
100
|
+
* @member {String|undefined} #_tooltipString
|
|
101
|
+
*/
|
|
102
|
+
this.bind('_tooltipString').to(this, 'tooltip', this, 'label', this, 'keystroke', this._getTooltipString.bind(this));
|
|
103
|
+
const template = {
|
|
104
|
+
tag: 'button',
|
|
105
|
+
attributes: {
|
|
106
|
+
class: [
|
|
107
|
+
'ck',
|
|
108
|
+
'ck-button',
|
|
109
|
+
bind.to('class'),
|
|
110
|
+
bind.if('isEnabled', 'ck-disabled', value => !value),
|
|
111
|
+
bind.if('isVisible', 'ck-hidden', value => !value),
|
|
112
|
+
bind.to('isOn', value => value ? 'ck-on' : 'ck-off'),
|
|
113
|
+
bind.if('withText', 'ck-button_with-text'),
|
|
114
|
+
bind.if('withKeystroke', 'ck-button_with-keystroke')
|
|
115
|
+
],
|
|
116
|
+
type: bind.to('type', value => value ? value : 'button'),
|
|
117
|
+
tabindex: bind.to('tabindex'),
|
|
118
|
+
'aria-labelledby': `ck-editor__aria-label_${ariaLabelUid}`,
|
|
119
|
+
'aria-disabled': bind.if('isEnabled', true, value => !value),
|
|
120
|
+
'aria-pressed': bind.to('isOn', value => this.isToggleable ? String(!!value) : false),
|
|
121
|
+
'data-cke-tooltip-text': bind.to('_tooltipString'),
|
|
122
|
+
'data-cke-tooltip-position': bind.to('tooltipPosition')
|
|
123
|
+
},
|
|
124
|
+
children: this.children,
|
|
125
|
+
on: {
|
|
126
|
+
click: bind.to(evt => {
|
|
127
|
+
// We can't make the button disabled using the disabled attribute, because it won't be focusable.
|
|
128
|
+
// Though, shouldn't this condition be moved to the button controller?
|
|
129
|
+
if (this.isEnabled) {
|
|
130
|
+
this.fire('execute');
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Prevent the default when button is disabled, to block e.g.
|
|
134
|
+
// automatic form submitting. See ckeditor/ckeditor5-link#74.
|
|
135
|
+
evt.preventDefault();
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// On Safari we have to force the focus on a button on click as it's the only browser
|
|
141
|
+
// that doesn't do that automatically. See #12115.
|
|
142
|
+
if (env.isSafari) {
|
|
143
|
+
template.on.mousedown = bind.to(evt => {
|
|
144
|
+
this.focus();
|
|
145
|
+
evt.preventDefault();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
this.setTemplate(template);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @inheritDoc
|
|
152
|
+
*/
|
|
153
|
+
render() {
|
|
154
|
+
super.render();
|
|
155
|
+
if (this.icon) {
|
|
156
|
+
this.iconView.bind('content').to(this, 'icon');
|
|
157
|
+
this.children.add(this.iconView);
|
|
158
|
+
}
|
|
159
|
+
this.children.add(this.labelView);
|
|
160
|
+
if (this.withKeystroke && this.keystroke) {
|
|
161
|
+
this.children.add(this.keystrokeView);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Focuses the {@link #element} of the button.
|
|
166
|
+
*/
|
|
167
|
+
focus() {
|
|
168
|
+
this.element.focus();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates a label view instance and binds it with button attributes.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @param {String} ariaLabelUid The aria label UID.
|
|
175
|
+
* @returns {module:ui/view~View}
|
|
176
|
+
*/
|
|
177
|
+
_createLabelView(ariaLabelUid) {
|
|
178
|
+
const labelView = new View();
|
|
179
|
+
const bind = this.bindTemplate;
|
|
180
|
+
labelView.setTemplate({
|
|
181
|
+
tag: 'span',
|
|
182
|
+
attributes: {
|
|
183
|
+
class: [
|
|
184
|
+
'ck',
|
|
185
|
+
'ck-button__label'
|
|
186
|
+
],
|
|
187
|
+
style: bind.to('labelStyle'),
|
|
188
|
+
id: `ck-editor__aria-label_${ariaLabelUid}`
|
|
189
|
+
},
|
|
190
|
+
children: [
|
|
191
|
+
{
|
|
192
|
+
text: this.bindTemplate.to('label')
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
});
|
|
196
|
+
return labelView;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Creates a view that displays a keystroke next to a {@link #labelView label }
|
|
200
|
+
* and binds it with button attributes.
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
* @returns {module:ui/view~View}
|
|
204
|
+
*/
|
|
205
|
+
_createKeystrokeView() {
|
|
206
|
+
const keystrokeView = new View();
|
|
207
|
+
keystrokeView.setTemplate({
|
|
208
|
+
tag: 'span',
|
|
209
|
+
attributes: {
|
|
210
|
+
class: [
|
|
211
|
+
'ck',
|
|
212
|
+
'ck-button__keystroke'
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
children: [
|
|
216
|
+
{
|
|
217
|
+
text: this.bindTemplate.to('keystroke', text => getEnvKeystrokeText(text))
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
return keystrokeView;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Gets the text for the tooltip from the combination of
|
|
225
|
+
* {@link #tooltip}, {@link #label} and {@link #keystroke} attributes.
|
|
226
|
+
*
|
|
227
|
+
* @private
|
|
228
|
+
* @see #tooltip
|
|
229
|
+
* @see #_tooltipString
|
|
230
|
+
* @param {Boolean|String|Function} tooltip Button tooltip.
|
|
231
|
+
* @param {String} label Button label.
|
|
232
|
+
* @param {String} keystroke Button keystroke.
|
|
233
|
+
* @returns {String}
|
|
234
|
+
*/
|
|
235
|
+
_getTooltipString(tooltip, label, keystroke) {
|
|
236
|
+
if (tooltip) {
|
|
237
|
+
if (typeof tooltip == 'string') {
|
|
238
|
+
return tooltip;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
if (keystroke) {
|
|
242
|
+
keystroke = getEnvKeystrokeText(keystroke);
|
|
243
|
+
}
|
|
244
|
+
if (tooltip instanceof Function) {
|
|
245
|
+
return tooltip(label, keystroke);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
return `${label}${keystroke ? ` (${keystroke})` : ''}`;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return '';
|
|
253
|
+
}
|
|
293
254
|
}
|
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module ui/button/switchbuttonview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import ButtonView from './buttonview';
|
|
12
|
-
|
|
13
10
|
import '../../theme/components/button/switchbutton.css';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The switch button view class.
|
|
17
13
|
*
|
|
@@ -29,71 +25,60 @@ import '../../theme/components/button/switchbutton.css';
|
|
|
29
25
|
* @extends module:ui/button/buttonview~ButtonView
|
|
30
26
|
*/
|
|
31
27
|
export default class SwitchButtonView extends ButtonView {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class: [
|
|
89
|
-
'ck',
|
|
90
|
-
'ck-button__toggle__inner'
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
return toggleSwitchView;
|
|
98
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
constructor(locale) {
|
|
32
|
+
super(locale);
|
|
33
|
+
this.isToggleable = true;
|
|
34
|
+
/**
|
|
35
|
+
* The toggle switch of the button.
|
|
36
|
+
*
|
|
37
|
+
* @readonly
|
|
38
|
+
* @member {module:ui/view~View} #toggleSwitchView
|
|
39
|
+
*/
|
|
40
|
+
this.toggleSwitchView = this._createToggleView();
|
|
41
|
+
this.extendTemplate({
|
|
42
|
+
attributes: {
|
|
43
|
+
class: 'ck-switchbutton'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
render() {
|
|
51
|
+
super.render();
|
|
52
|
+
this.children.add(this.toggleSwitchView);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a toggle child view.
|
|
56
|
+
*
|
|
57
|
+
* @private
|
|
58
|
+
* @returns {module:ui/view~View}
|
|
59
|
+
*/
|
|
60
|
+
_createToggleView() {
|
|
61
|
+
const toggleSwitchView = new View();
|
|
62
|
+
toggleSwitchView.setTemplate({
|
|
63
|
+
tag: 'span',
|
|
64
|
+
attributes: {
|
|
65
|
+
class: [
|
|
66
|
+
'ck',
|
|
67
|
+
'ck-button__toggle'
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
{
|
|
72
|
+
tag: 'span',
|
|
73
|
+
attributes: {
|
|
74
|
+
class: [
|
|
75
|
+
'ck',
|
|
76
|
+
'ck-button__toggle__inner'
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
return toggleSwitchView;
|
|
83
|
+
}
|
|
99
84
|
}
|