@componyx/ui 0.0.0-stage → 1.0.3
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/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Databinder.js +602 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
package/Button/Button.js
ADDED
|
@@ -0,0 +1,1398 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
import '../Base/Base.js';
|
|
3
|
+
import '../Base/Library.js';
|
|
4
|
+
|
|
5
|
+
(function (window)
|
|
6
|
+
{
|
|
7
|
+
/**
|
|
8
|
+
* Button class.
|
|
9
|
+
* @class
|
|
10
|
+
* @memberof componyx.UI
|
|
11
|
+
* @augments componyx.UI.base.Component
|
|
12
|
+
* @mixes componyx.UI.base.methods
|
|
13
|
+
* @param {String} id The id of the component.
|
|
14
|
+
* @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
|
|
15
|
+
* @returns {Object} An instance of the component.
|
|
16
|
+
*/
|
|
17
|
+
componyx.UI.Button = function Button(id, properties)
|
|
18
|
+
{
|
|
19
|
+
// define private properties
|
|
20
|
+
let _instance = this,
|
|
21
|
+
_contentElement,
|
|
22
|
+
_sizeOption = componyx.UI.Button.SizeOption,
|
|
23
|
+
_typeOption = componyx.UI.Button.TypeOption,
|
|
24
|
+
_expandDirectionOption = componyx.UI.Button.ExpandDirectionOption,
|
|
25
|
+
_alignOption = componyx.UI.Button.AlignOption,
|
|
26
|
+
_decorationOption = componyx.UI.Button.DecorationOption,
|
|
27
|
+
_divCommand, _divExpand, _handlers = [], _anchor,
|
|
28
|
+
_ripple = new Map(),
|
|
29
|
+
_rippleTimerId,
|
|
30
|
+
_isKeyboardNavigation,
|
|
31
|
+
_classOption =
|
|
32
|
+
{
|
|
33
|
+
SIZE_PREFIX: 'size-',
|
|
34
|
+
CONTENT_ALIGN: 'content',
|
|
35
|
+
SPLIT: 'split',
|
|
36
|
+
TRANSPARENT: 'lucent',
|
|
37
|
+
BASIC: 'basic',
|
|
38
|
+
PRIMARY: 'pri',
|
|
39
|
+
BORDER: 'border',
|
|
40
|
+
COMMAND: 'command',
|
|
41
|
+
ICON: 'icon',
|
|
42
|
+
CONTENT_HOLDER: 'content-holder',
|
|
43
|
+
EXPAND: 'expand',
|
|
44
|
+
EXPAND_ICON: 'expand-icon',
|
|
45
|
+
CHECK: 'check',
|
|
46
|
+
RADIO: 'radio',
|
|
47
|
+
RIPPLE: 'ripple',
|
|
48
|
+
RIPPLE_MASK: 'ripple-mask',
|
|
49
|
+
UNDERLINE: 'line-under',
|
|
50
|
+
OVERLINE: 'line-over',
|
|
51
|
+
FRONTLINE: 'line-front',
|
|
52
|
+
BACKLINE: 'line-back'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// define public properties
|
|
56
|
+
/**
|
|
57
|
+
* Gets or sets the content align class. This class is followed by a hyphen (-) with the current align option and is appended to the button class. Default: content-left
|
|
58
|
+
* @type {String}
|
|
59
|
+
*/
|
|
60
|
+
this.cssClassContentAlign = '';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets or sets the icon align class. This class is followed by a hyphen (-) with the current align option and is appended to the button class. Default: icon-left
|
|
64
|
+
* @type {String}
|
|
65
|
+
*/
|
|
66
|
+
this.cssClassIconAlign = '';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets or sets the css class for a split button.
|
|
70
|
+
* @type {String}
|
|
71
|
+
*/
|
|
72
|
+
this.cssClassSplit = '';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Gets or sets the css class of the command button in a split button.
|
|
76
|
+
* @type {String}
|
|
77
|
+
*/
|
|
78
|
+
this.cssClassCommand = '';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Gets or sets the css class of the expand button in a split button.
|
|
82
|
+
* @type {String}
|
|
83
|
+
*/
|
|
84
|
+
this.cssClassExpand = '';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Gets or sets the css class of the expand icon in a split button.
|
|
88
|
+
* @type {String}
|
|
89
|
+
*/
|
|
90
|
+
this.cssClassExpandIcon = '';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Gets or sets the css class of the button icon.
|
|
94
|
+
* @type {String}
|
|
95
|
+
*/
|
|
96
|
+
this.cssClassIcon = '';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Gets or sets the css class of the content holder within the button.
|
|
100
|
+
* @type {String}
|
|
101
|
+
*/
|
|
102
|
+
this.cssClassContentHolder = '';
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gets or sets the shortcut key to trigger this button e.g. 'z', 'ctrl+z', 'alt+s'. If no modifier is provided, `ctrl` is assumed by default.
|
|
106
|
+
* @type {String|null}
|
|
107
|
+
*/
|
|
108
|
+
this.shortcutKey = null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Gets or sets the DOM element (or its identifier, or a function returning it) within which this shortcut is active. If `null`, the shortcut is globally active (i.e., it works anywhere).
|
|
112
|
+
* @type {HTMLElement|String|Function|null}
|
|
113
|
+
*/
|
|
114
|
+
this.shortcutScope = null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Gets or sets a value indicating if the button keyboard navigation for expanding/collapsing is enabled when it has an expandable feature (menuId, boxId or expandCommand).
|
|
118
|
+
* @type {Boolean}
|
|
119
|
+
*/
|
|
120
|
+
this.keyboardExpand = true;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Gets or sets the href (hypertext reference) of the button. Applies to non-split buttons only.
|
|
124
|
+
* @type {String|null}
|
|
125
|
+
*/
|
|
126
|
+
this.href = null;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Gets or sets the href target of the button. Applies to non-split buttons only.
|
|
130
|
+
* @type {String|null}
|
|
131
|
+
*/
|
|
132
|
+
this.target = null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Gets or sets the command action of the button.
|
|
136
|
+
* @type {Function|String|null}
|
|
137
|
+
*/
|
|
138
|
+
this.command = null;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets or sets an expand command action.
|
|
142
|
+
* @type {Function|String|null}
|
|
143
|
+
*/
|
|
144
|
+
this.expandCommand = null;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Gets or sets an collapse command action.
|
|
148
|
+
* @type {Function|String|null}
|
|
149
|
+
*/
|
|
150
|
+
this.collapseCommand = null;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Gets or sets the text of the button.
|
|
154
|
+
* @type {String|null}
|
|
155
|
+
*/
|
|
156
|
+
this.text = null;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Gets or sets the URL of the icon.
|
|
160
|
+
* @type {String|null}
|
|
161
|
+
*/
|
|
162
|
+
this.iconUrl = null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Gets or sets the size option.
|
|
166
|
+
* @type {componyx.UI.Button.SizeOption}
|
|
167
|
+
*/
|
|
168
|
+
this.size = _sizeOption.MEDIUM;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Gets or sets the content alignment option.
|
|
172
|
+
* @type {componyx.UI.Button.AlignOption}
|
|
173
|
+
*/
|
|
174
|
+
this.contentAlign = _alignOption.CENTER;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Gets or sets the icon alignment option.
|
|
178
|
+
* @type {componyx.UI.Button.AlignOption}
|
|
179
|
+
*/
|
|
180
|
+
this.iconAlign = _alignOption.LEFT;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Gets or sets the type of the button.
|
|
184
|
+
* @type {componyx.UI.Button.TypeOption}
|
|
185
|
+
*/
|
|
186
|
+
this.type = _typeOption.COMMANDBUTTON;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Gets or sets the expand direction of the button.
|
|
190
|
+
* @type {componyx.UI.Button.ExpandDirectionOption}
|
|
191
|
+
*/
|
|
192
|
+
this.expandDirection = _expandDirectionOption.DOWN;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Gets or sets the decoration type used when the button is hovered/selected.
|
|
196
|
+
* @type {componyx.UI.Button.DecorationOption}
|
|
197
|
+
*/
|
|
198
|
+
this.decoration = _decorationOption.BACKGROUND;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Gets or sets the radio group id.
|
|
202
|
+
* @type {String|null}
|
|
203
|
+
*/
|
|
204
|
+
this.radioGroupId = null;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Gets or sets a value indicating if the identifier of the component is rendered in the HTML output of the root element.
|
|
208
|
+
* @type {Boolean}
|
|
209
|
+
*/
|
|
210
|
+
this.renderId = true;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets or sets a value indicating whether the PostBack event is automatically fired.
|
|
214
|
+
* @type {Boolean}
|
|
215
|
+
*/
|
|
216
|
+
this.autoPostBack = false;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Gets or sets if the icon span tag should be rendered.
|
|
220
|
+
* @type {Boolean}
|
|
221
|
+
*/
|
|
222
|
+
this.hasIcon = false;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Gets or sets a value indicating whether the button is disabled.
|
|
226
|
+
* @type {Boolean}
|
|
227
|
+
*/
|
|
228
|
+
this.disabled = false;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Gets or sets a value indicating whether the button is selected.
|
|
232
|
+
* @type {Boolean}
|
|
233
|
+
*/
|
|
234
|
+
this.selected = false;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Gets or sets a value indicating whether the button is in expanded state.
|
|
238
|
+
* @type {Boolean}
|
|
239
|
+
*/
|
|
240
|
+
this.expanded = false;
|
|
241
|
+
/**
|
|
242
|
+
* Gets or sets a value indicating if the button has two actions.
|
|
243
|
+
* @type {Boolean}
|
|
244
|
+
*/
|
|
245
|
+
this.split = false;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Gets or sets a value indicating if the button's default background color is transparent.
|
|
249
|
+
* @type {Boolean}
|
|
250
|
+
*/
|
|
251
|
+
this.transparent = false;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Gets or sets a value indicating if the button's default border color is transparent.
|
|
255
|
+
* @type {Boolean}
|
|
256
|
+
*/
|
|
257
|
+
this.transparentBorder = true;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Gets or sets a value indicating if the button is a primary button. When disabled the button's default style will be less prominent (basic) unless styled otherwise.
|
|
261
|
+
* @type {Boolean}
|
|
262
|
+
*/
|
|
263
|
+
this.primary = true;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Gets or sets a value indicating if the ripple animation is activated on a command/expand click event.
|
|
267
|
+
* @type {Boolean}
|
|
268
|
+
*/
|
|
269
|
+
this.rippleAnimation = true;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Gets or sets which menu to expand when the expand button is clicked.
|
|
273
|
+
* @type {String|null}
|
|
274
|
+
*/
|
|
275
|
+
this.menuId = null;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Gets or sets a menu root item to expand on the corresponding menu when the expand button is clicked.
|
|
279
|
+
* @type {String|null}
|
|
280
|
+
*/
|
|
281
|
+
this.menuItemId = null;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Gets or sets which box to expand when the expand button is clicked.
|
|
285
|
+
* @type {String|null}
|
|
286
|
+
*/
|
|
287
|
+
this.boxId = null;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Gets or sets the tooltip manager used to display tooltips.
|
|
291
|
+
* @type {String|null}
|
|
292
|
+
*/
|
|
293
|
+
this.tooltipManagerId = null;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Gets or sets the id of the tooltip to show.
|
|
297
|
+
* @type {String|null}
|
|
298
|
+
*/
|
|
299
|
+
this.tooltipId = null;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Gets the element which contains the button content.
|
|
303
|
+
* @type {HTMLElement}
|
|
304
|
+
*/
|
|
305
|
+
Object.defineProperty(this, 'contentElement',
|
|
306
|
+
{
|
|
307
|
+
get: function () { return _contentElement; }
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @class
|
|
313
|
+
* @augments componyx.UI.base.Events
|
|
314
|
+
* @memberof componyx.UI.Button
|
|
315
|
+
* @property {componyx.UI.base.Event} onFocus - Fires when the button is focused. @see {@link componyx.UI.base.EventArgs}
|
|
316
|
+
* @property {componyx.UI.base.Event} onBlur - Fires when the button is blurred. @see {@link componyx.UI.base.EventArgs}
|
|
317
|
+
* @property {componyx.UI.base.Event} onPointerEnter - Fires on pointerenter. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
318
|
+
* @property {componyx.UI.base.Event} onPointerLeave - Fires on pointerleave. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
319
|
+
* @property {componyx.UI.base.Event} onPointerDown - Fires on pointerdown. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
320
|
+
* @property {componyx.UI.base.Event} onPointerUp - Fires on pointerup. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
321
|
+
* @property {componyx.UI.base.Event} onDblClick - Fires on double click. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
322
|
+
* @property {componyx.UI.base.Event} onSelect - Fires on select. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
323
|
+
* @property {componyx.UI.base.Event} onDeselect - Fires on deselect. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
324
|
+
* @property {componyx.UI.base.Event} onCommandClick - Fires on command click. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
325
|
+
* @property {componyx.UI.base.Event} onCommandPointerEnter - Fires on command pointerenter. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
326
|
+
* @property {componyx.UI.base.Event} onCommandPointerLeave - Fires on command pointerleave. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
327
|
+
* @property {componyx.UI.base.Event} onCommandPointerDown - Fires on command pointerdown. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
328
|
+
* @property {componyx.UI.base.Event} onCommandPointerUp - Fires on command pointerup. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
329
|
+
* @property {componyx.UI.base.Event} onCommandDblClick - Fires on command double click. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
330
|
+
* @property {componyx.UI.base.Event} onExpandClick - Fires on expand click. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
331
|
+
* @property {componyx.UI.base.Event} onExpandPointerEnter - Fires on expand pointerenter. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
332
|
+
* @property {componyx.UI.base.Event} onExpandPointerLeave - Fires on expand pointerleave. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
333
|
+
* @property {componyx.UI.base.Event} onExpandPointerDown - Fires on expand pointerdown. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
334
|
+
* @property {componyx.UI.base.Event} onExpandPointerUp - Fires on expand pointerup. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
335
|
+
* @property {componyx.UI.base.Event} onExpandDblClick - Fires on expand double click. @see {@link componyx.UI.Button.ButtonEventArgs}
|
|
336
|
+
* @see {@link componyx.UI.base.Events}
|
|
337
|
+
*/
|
|
338
|
+
function ButtonEvents(events)
|
|
339
|
+
{
|
|
340
|
+
Object.assign(this, events);
|
|
341
|
+
|
|
342
|
+
// Base events
|
|
343
|
+
const baseEvents = [
|
|
344
|
+
'Focus', 'Blur',
|
|
345
|
+
'PointerEnter', 'PointerLeave',
|
|
346
|
+
'PointerDown', 'PointerUp', 'DblClick',
|
|
347
|
+
'Select', 'Deselect'
|
|
348
|
+
];
|
|
349
|
+
|
|
350
|
+
baseEvents.forEach(name =>
|
|
351
|
+
{
|
|
352
|
+
this[`on${name}`] = $base.static.createEvent(`on${name}`);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Command + Expand groups
|
|
356
|
+
['Command', 'Expand'].forEach(prefix =>
|
|
357
|
+
{
|
|
358
|
+
['Click', 'PointerEnter', 'PointerLeave', 'PointerDown', 'PointerUp', 'DblClick']
|
|
359
|
+
.forEach(name =>
|
|
360
|
+
{
|
|
361
|
+
this[`on${prefix}${name}`] = $base.static.createEvent(`on${prefix}${name}`);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Button events
|
|
367
|
+
* @type {componyx.UI.Button.ButtonEvents}
|
|
368
|
+
*/
|
|
369
|
+
this.events = new ButtonEvents(this.events);
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @typedef {Object} componyx.UI.Button.ButtonEventArgs
|
|
374
|
+
* @property {componyx.UI.Button} Button - The Button instance.
|
|
375
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
376
|
+
* @property {Event} eventArgs.event - The original event object.
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
// inherit base instance members
|
|
380
|
+
$base.Component.apply(this, [id, properties]);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* A value indicating if the last action was triggered via keyboard navigation.
|
|
385
|
+
* @returns {boolean}
|
|
386
|
+
*/
|
|
387
|
+
this.isKeyboardNavigation = function ()
|
|
388
|
+
{
|
|
389
|
+
return _isKeyboardNavigation;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Selects the button
|
|
394
|
+
*/
|
|
395
|
+
this.toggleSelect = function ()
|
|
396
|
+
{
|
|
397
|
+
toggleSelect();
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Selects the button
|
|
402
|
+
*/
|
|
403
|
+
this.select = function ()
|
|
404
|
+
{
|
|
405
|
+
select();
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Deselects the button
|
|
410
|
+
*/
|
|
411
|
+
this.deselect = function ()
|
|
412
|
+
{
|
|
413
|
+
deselect();
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Enables the button
|
|
418
|
+
*/
|
|
419
|
+
this.enable = function ()
|
|
420
|
+
{
|
|
421
|
+
enable();
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Disables the button
|
|
426
|
+
* @param {Boolean} [keepSelected=false] A value indicating if the button must remain selected.
|
|
427
|
+
*/
|
|
428
|
+
this.disable = function (keepSelected)
|
|
429
|
+
{
|
|
430
|
+
disable(keepSelected);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Sets focus on the button.
|
|
435
|
+
*/
|
|
436
|
+
this.focus = function ()
|
|
437
|
+
{
|
|
438
|
+
focus();
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Removes focus from the button.
|
|
443
|
+
*/
|
|
444
|
+
this.blur = function ()
|
|
445
|
+
{
|
|
446
|
+
blur();
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Executes the command click event.
|
|
451
|
+
*/
|
|
452
|
+
this.commandClick = function ()
|
|
453
|
+
{
|
|
454
|
+
commandClick();
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Executes the command click event.
|
|
459
|
+
*/
|
|
460
|
+
this.expandClick = function ()
|
|
461
|
+
{
|
|
462
|
+
toggleExpand();
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Gets the command button element.
|
|
467
|
+
*/
|
|
468
|
+
this.getCommandButton = function ()
|
|
469
|
+
{
|
|
470
|
+
return (_instance.split) ? _divCommand : _instance.element;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Gets the expand button element.
|
|
475
|
+
*/
|
|
476
|
+
this.getExpandButton = function ()
|
|
477
|
+
{
|
|
478
|
+
return (_instance.split) ? _divExpand : null;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Updates the button content with the specified template or text
|
|
483
|
+
*/
|
|
484
|
+
this.updateContent = function ()
|
|
485
|
+
{
|
|
486
|
+
applyContent();
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Sets the content template.
|
|
491
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content The content template.
|
|
492
|
+
*/
|
|
493
|
+
this.setContentTemplate = function (content)
|
|
494
|
+
{
|
|
495
|
+
_instance.addTemplate('Content', content, false);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Clones the source component. This method should not be invoked by client code directly but only from inside component code.
|
|
500
|
+
* @param {componyx.UI.base.Component} source The source component.
|
|
501
|
+
* @param {Boolean} [cloneTemplates=true] A value indicating if templates are cloned.
|
|
502
|
+
* @param {Boolean} [cloneEvents=true] A value indicating if events are cloned.
|
|
503
|
+
* @see {@link componyx.UI.base.methods#clone}
|
|
504
|
+
* @function
|
|
505
|
+
* @protected
|
|
506
|
+
*/
|
|
507
|
+
this.clone = function (source, parent, cloneTemplates, cloneEvents)
|
|
508
|
+
{
|
|
509
|
+
$base.methods.clone.call(_instance, source, parent, cloneTemplates, cloneEvents);
|
|
510
|
+
|
|
511
|
+
if (source)
|
|
512
|
+
_instance.command = source.command;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Renders the component
|
|
517
|
+
*/
|
|
518
|
+
this.render = function ()
|
|
519
|
+
{
|
|
520
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING)
|
|
521
|
+
{
|
|
522
|
+
// call base render and return
|
|
523
|
+
$base.methods.render.call(_instance, preRender, 'button', true, 'a');
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// render logic after loading resources
|
|
528
|
+
draw();
|
|
529
|
+
|
|
530
|
+
componyx.UI.Button.ShortcutManager.registerButton(_instance);
|
|
531
|
+
|
|
532
|
+
if (!_instance.renderId)
|
|
533
|
+
_instance.element.removeAttribute('id');
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Handles the post render procedure.
|
|
538
|
+
*/
|
|
539
|
+
this.postRender = function ()
|
|
540
|
+
{
|
|
541
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING) // extra safety to never execute a postRender when the component state is incorrect
|
|
542
|
+
return;
|
|
543
|
+
|
|
544
|
+
if (_instance.tooltipManagerId && _instance.tooltipId)
|
|
545
|
+
$UI.store[_instance.tooltipManagerId].addTrigger(_instance.element, _instance.tooltipId);
|
|
546
|
+
|
|
547
|
+
let el = _instance.split ? _instance.getExpandButton() : _instance.element;
|
|
548
|
+
|
|
549
|
+
if (_instance.menuId)
|
|
550
|
+
el.setAttribute('aria-haspopup', 'menu');
|
|
551
|
+
else if (_instance.boxId)
|
|
552
|
+
el.setAttribute('aria-haspopup', 'dialog');
|
|
553
|
+
|
|
554
|
+
$base.methods.postRender.call(_instance);
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Destroys the component.
|
|
559
|
+
* @see {@link componyx.UI.base.methods#destroy}
|
|
560
|
+
*/
|
|
561
|
+
this.destroy = function (...args)
|
|
562
|
+
{
|
|
563
|
+
dispose();
|
|
564
|
+
$base.methods.destroy.call(this, ...args);
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
function preRender()
|
|
568
|
+
{
|
|
569
|
+
// initialize script and css
|
|
570
|
+
return ['Button'];
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function draw()
|
|
574
|
+
{
|
|
575
|
+
let button = _instance.element,
|
|
576
|
+
spanIcon = document.createElement('span'),
|
|
577
|
+
expandDirection = ($lib.isEmpty(_instance.expandDirection)) ? _expandDirectionOption.DOWN : _instance.expandDirection,
|
|
578
|
+
expandable = (_instance.menuId || _instance.boxId || _instance.expandCommand),
|
|
579
|
+
cssClassSplit = null,
|
|
580
|
+
decoration = getDecoration(_instance.decoration);
|
|
581
|
+
|
|
582
|
+
_contentElement = document.createElement('div');
|
|
583
|
+
|
|
584
|
+
_instance.command = convertCommand(_instance.command);
|
|
585
|
+
_instance.expandCommand = convertCommand(_instance.expandCommand);
|
|
586
|
+
|
|
587
|
+
if (_instance.command && expandable)
|
|
588
|
+
_instance.split = true;
|
|
589
|
+
|
|
590
|
+
button.classList.add(_instance.primary ? _classOption.PRIMARY : _classOption.BASIC);
|
|
591
|
+
|
|
592
|
+
if (_instance.transparent)
|
|
593
|
+
button.classList.add(_classOption.TRANSPARENT);
|
|
594
|
+
|
|
595
|
+
if (!_instance.transparentBorder)
|
|
596
|
+
button.classList.add(_classOption.BORDER);
|
|
597
|
+
|
|
598
|
+
if (decoration)
|
|
599
|
+
button.classList.add(decoration);
|
|
600
|
+
|
|
601
|
+
if (_instance.type == _typeOption.CHECKBUTTON)
|
|
602
|
+
button.classList.add(_classOption.CHECK);
|
|
603
|
+
else if (_instance.type == _typeOption.RADIOBUTTON)
|
|
604
|
+
button.classList.add(_classOption.RADIO);
|
|
605
|
+
|
|
606
|
+
if (_instance.size && _instance.size !== _sizeOption.MEDIUM)
|
|
607
|
+
button.classList.add(_classOption.SIZE_PREFIX + _instance.size);
|
|
608
|
+
|
|
609
|
+
_contentElement.className = _instance.cssClassContentHolder || _classOption.CONTENT_HOLDER;
|
|
610
|
+
|
|
611
|
+
if (_instance.split)
|
|
612
|
+
{
|
|
613
|
+
_divCommand = document.createElement('div');
|
|
614
|
+
_divExpand = document.createElement('div');
|
|
615
|
+
|
|
616
|
+
cssClassSplit = _instance.cssClassSplit || _classOption.SPLIT;
|
|
617
|
+
button.classList.add(cssClassSplit, _expandDirectionOption.getName(expandDirection));
|
|
618
|
+
|
|
619
|
+
_divCommand.className = _instance.cssClassCommand || _classOption.COMMAND;
|
|
620
|
+
_divExpand.className = _instance.cssClassExpand || _classOption.EXPAND;
|
|
621
|
+
|
|
622
|
+
if (_instance.hasIcon)
|
|
623
|
+
_divCommand.appendChild(spanIcon);
|
|
624
|
+
|
|
625
|
+
_divCommand.appendChild(_contentElement);
|
|
626
|
+
button.appendChild(_divCommand);
|
|
627
|
+
|
|
628
|
+
createExpandIcon(_divExpand);
|
|
629
|
+
button.appendChild(_divExpand);
|
|
630
|
+
}
|
|
631
|
+
else
|
|
632
|
+
{
|
|
633
|
+
if (_instance.hasIcon)
|
|
634
|
+
button.appendChild(spanIcon);
|
|
635
|
+
|
|
636
|
+
button.appendChild(_contentElement);
|
|
637
|
+
|
|
638
|
+
if (expandable)
|
|
639
|
+
{
|
|
640
|
+
button.classList.add(_expandDirectionOption.getName(expandDirection));
|
|
641
|
+
createExpandIcon(button);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
setAnchor();
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (!_instance.href || _instance.split)
|
|
648
|
+
button.setAttribute('role', 'button');
|
|
649
|
+
|
|
650
|
+
setTabIndex((_instance.disabled) ? -1 : _instance.tabIndex);
|
|
651
|
+
|
|
652
|
+
if (_instance.hasIcon)
|
|
653
|
+
{
|
|
654
|
+
if (_instance.iconAlign === _alignOption.CENTER)
|
|
655
|
+
_instance.iconAlign = _alignOption.LEFT;
|
|
656
|
+
else if (_instance.iconAlign === _alignOption.RIGHT)
|
|
657
|
+
_contentElement.parentNode.insertBefore(_contentElement, spanIcon);
|
|
658
|
+
|
|
659
|
+
button.className += ' ' + (_instance.cssClassIconAlign || _classOption.ICON) + '-' + getAlignment(_instance.iconAlign, _alignOption.LEFT);
|
|
660
|
+
spanIcon.className = _instance.cssClassIcon || _classOption.ICON;
|
|
661
|
+
spanIcon.classList.add(_classOption.ICON); // always include the base icon class
|
|
662
|
+
|
|
663
|
+
if (_instance.iconURL)
|
|
664
|
+
spanIcon.style.backgroundImage = 'url(' + _instance.iconURL + ')';
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
applyContent();
|
|
668
|
+
|
|
669
|
+
if (!_instance.disabled)
|
|
670
|
+
bindGlobalEvents(button, _divCommand, _divExpand);
|
|
671
|
+
|
|
672
|
+
if (_instance.selected)
|
|
673
|
+
{
|
|
674
|
+
_instance.selected = false;
|
|
675
|
+
select();
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (_instance.disabled)
|
|
679
|
+
disable(true);
|
|
680
|
+
|
|
681
|
+
if (!_instance.menuId && !_instance.boxId)
|
|
682
|
+
{
|
|
683
|
+
_instance.postRender();
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
if (_instance.menuId)
|
|
688
|
+
{
|
|
689
|
+
if ($UI.store[_instance.menuId].renderState == $base.static.RenderState.RENDERED)
|
|
690
|
+
{
|
|
691
|
+
_instance.postRender();
|
|
692
|
+
}
|
|
693
|
+
else
|
|
694
|
+
{
|
|
695
|
+
$UI.store[_instance.menuId].events.onPostRender.priorityAdd(function ()
|
|
696
|
+
{
|
|
697
|
+
_instance.postRender();
|
|
698
|
+
}, null);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
else if ($UI.store[_instance.boxId].renderState == $base.static.RenderState.RENDERED)
|
|
702
|
+
{
|
|
703
|
+
_instance.postRender();
|
|
704
|
+
}
|
|
705
|
+
else
|
|
706
|
+
{
|
|
707
|
+
$UI.store[_instance.boxId].events.onPostRender.priorityAdd(function ()
|
|
708
|
+
{
|
|
709
|
+
_instance.postRender();
|
|
710
|
+
}, null);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function setAnchor()
|
|
715
|
+
{
|
|
716
|
+
if ($lib.isEmpty(_instance.href))
|
|
717
|
+
return;
|
|
718
|
+
|
|
719
|
+
let button = _instance.element,
|
|
720
|
+
a = button;
|
|
721
|
+
|
|
722
|
+
if (button.nodeName.toLowerCase() !== 'a') // not anchor tag?
|
|
723
|
+
_anchor = a = $lib.element(button, '', 'a');
|
|
724
|
+
|
|
725
|
+
a.href = _instance.href;
|
|
726
|
+
|
|
727
|
+
if (_instance.target)
|
|
728
|
+
a.target = _instance.target;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function getDecoration(type)
|
|
732
|
+
{
|
|
733
|
+
if (!type)
|
|
734
|
+
return '';
|
|
735
|
+
|
|
736
|
+
if (type == _decorationOption.UNDERLINE)
|
|
737
|
+
return _classOption.UNDERLINE;
|
|
738
|
+
else if (type == _decorationOption.OVERLINE)
|
|
739
|
+
return _classOption.OVERLINE;
|
|
740
|
+
else if (type == _decorationOption.FRONTLINE)
|
|
741
|
+
return _classOption.FRONTLINE;
|
|
742
|
+
else
|
|
743
|
+
return _classOption.BACKLINE;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function convertCommand(command)
|
|
747
|
+
{
|
|
748
|
+
return $base.static.getMethod(command);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function applyContent()
|
|
752
|
+
{
|
|
753
|
+
let button = _instance.element,
|
|
754
|
+
cssClassContent = $lib.format('{0}-{1}', _instance.cssClassContentAlign || _classOption.CONTENT_ALIGN, getAlignment(_instance.contentAlign));
|
|
755
|
+
|
|
756
|
+
_contentElement.style.display = _contentElement.innerHTML = '';
|
|
757
|
+
button.classList.remove(cssClassContent);
|
|
758
|
+
|
|
759
|
+
if (_instance.hasTemplate('Content'))
|
|
760
|
+
_instance.applyTemplate(_contentElement, 'Content');
|
|
761
|
+
else if (_instance.text != null)
|
|
762
|
+
_contentElement.innerHTML = _instance.text;
|
|
763
|
+
|
|
764
|
+
if (!$lib.isEmpty(_contentElement.innerHTML))
|
|
765
|
+
button.classList.add(cssClassContent);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function createExpandIcon(container)
|
|
769
|
+
{
|
|
770
|
+
let spanExpandIcon = document.createElement('span');
|
|
771
|
+
spanExpandIcon.className = _instance.cssClassExpandIcon || _classOption.EXPAND_ICON;
|
|
772
|
+
container.appendChild(spanExpandIcon);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function bindGlobalEvents(button, divCommand, divExpand)
|
|
776
|
+
{
|
|
777
|
+
let element = _instance.split ? divCommand : button,
|
|
778
|
+
expandable = (_instance.menuId || _instance.boxId || _instance.expandCommand),
|
|
779
|
+
clickEnd = 'pointerup pointerenter pointerleave';
|
|
780
|
+
|
|
781
|
+
_handlers = [];
|
|
782
|
+
|
|
783
|
+
if (_instance.keyboardExpand && expandable)
|
|
784
|
+
{
|
|
785
|
+
$lib.on(_instance.element, 'keydown', handleKeyboardExpand);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Helper to bind focus and blur with _instance context
|
|
789
|
+
const bindFocusBlur = (el) =>
|
|
790
|
+
{
|
|
791
|
+
bind(el, 'focus', () => _instance.onFocus.call(_instance));
|
|
792
|
+
bind(el, 'blur', () => _instance.onBlur.call(_instance));
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// Consolidate pointerdown and pointerup/leave bindings on relevant elements
|
|
796
|
+
const elementsToBind = _instance.split ? [divCommand, divExpand] : [button];
|
|
797
|
+
|
|
798
|
+
elementsToBind.forEach(el =>
|
|
799
|
+
{
|
|
800
|
+
bind(el, 'pointerdown', $lib.addClass, [el, 'pressed']);
|
|
801
|
+
bind(el, clickEnd, $lib.removeClass, [el, 'pressed']);
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
if (_instance.split)
|
|
805
|
+
{
|
|
806
|
+
bindFocusBlur(divExpand);
|
|
807
|
+
bindFocusBlur(divCommand);
|
|
808
|
+
|
|
809
|
+
if (_instance.rippleAnimation)
|
|
810
|
+
{
|
|
811
|
+
createRipple(divExpand);
|
|
812
|
+
bind(divExpand, 'pointerdown', rippleAnimation, [divExpand], _instance);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
bind(divExpand, 'click', e => { return toggleExpand(); });
|
|
816
|
+
bindEvents(divExpand, 'onExpand');
|
|
817
|
+
}
|
|
818
|
+
else
|
|
819
|
+
{
|
|
820
|
+
bindFocusBlur(button);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (_instance.rippleAnimation)
|
|
824
|
+
{
|
|
825
|
+
createRipple(element);
|
|
826
|
+
bind(element, 'pointerdown', rippleAnimation, [element], _instance);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
bind(element, 'click', e =>
|
|
830
|
+
{
|
|
831
|
+
if (_instance.type > 0)
|
|
832
|
+
toggleSelect();
|
|
833
|
+
|
|
834
|
+
return commandClick();
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
bind(button, 'keydown', e =>
|
|
838
|
+
{
|
|
839
|
+
if (e.key === 'Enter' || e.key === ' ')
|
|
840
|
+
{
|
|
841
|
+
rippleAnimation(element, e);
|
|
842
|
+
|
|
843
|
+
if (_instance.type > 0)
|
|
844
|
+
toggleSelect();
|
|
845
|
+
|
|
846
|
+
_isKeyboardNavigation = true;
|
|
847
|
+
return commandClick();
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
bindEvents(element, 'onCommand');
|
|
852
|
+
bindEvents(button, 'on');
|
|
853
|
+
|
|
854
|
+
if (_anchor)
|
|
855
|
+
{
|
|
856
|
+
bind(button, 'click', () => { _anchor.click(); _instance.element.focus(); });
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function bind(el, type, fn, args, context)
|
|
861
|
+
{
|
|
862
|
+
let id = $lib.on(el, type, fn, args, context);
|
|
863
|
+
_handlers.push({ el: el, type: type, id: id });
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function bindEvents(element, prefix)
|
|
867
|
+
{
|
|
868
|
+
$lib.each(['PointerEnter', 'PointerLeave', 'PointerDown', 'PointerUp', 'DblClick'], function (event)
|
|
869
|
+
{
|
|
870
|
+
bind(element, event.toLowerCase(), function ()
|
|
871
|
+
{
|
|
872
|
+
_instance.events[prefix + event].fire(_instance, createEventArgs());
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function unbindEvents()
|
|
878
|
+
{
|
|
879
|
+
$lib.each(_handlers, function (item)
|
|
880
|
+
{
|
|
881
|
+
$lib.off(item.el, item.type, item.id);
|
|
882
|
+
});
|
|
883
|
+
_handlers = [];
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function createEventArgs()
|
|
887
|
+
{
|
|
888
|
+
return { event: $lib.event };
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function handleKeyboardExpand(event)
|
|
892
|
+
{
|
|
893
|
+
if (_instance.disabled)
|
|
894
|
+
return;
|
|
895
|
+
|
|
896
|
+
const key = event.key,
|
|
897
|
+
expanded = _instance.expanded,
|
|
898
|
+
direction = _instance.expandDirection || _expandDirectionOption.DOWN,
|
|
899
|
+
isVertical = direction === _expandDirectionOption.UP || direction === _expandDirectionOption.DOWN,
|
|
900
|
+
shouldExpand = !expanded && ((isVertical && key === 'ArrowDown') || (!isVertical && key === 'ArrowRight')),
|
|
901
|
+
shouldCollapse = expanded && (key === 'Escape' || (isVertical && key === 'ArrowUp') || (!isVertical && key === 'ArrowLeft'));
|
|
902
|
+
|
|
903
|
+
if (shouldExpand || shouldCollapse)
|
|
904
|
+
{
|
|
905
|
+
_isKeyboardNavigation = true;
|
|
906
|
+
toggleExpand();
|
|
907
|
+
|
|
908
|
+
if (_instance.split)
|
|
909
|
+
rippleAnimation(_divExpand, event);
|
|
910
|
+
|
|
911
|
+
_isKeyboardNavigation = false;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function createRipple(el)
|
|
916
|
+
{
|
|
917
|
+
let ripple = $lib.element($lib.element(el), '', 'span');
|
|
918
|
+
_ripple.set(el, ripple);
|
|
919
|
+
ripple.parentNode.className = _classOption.RIPPLE_MASK;
|
|
920
|
+
ripple.parentNode.style.display = 'none';
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function rippleAnimation(el, e)
|
|
924
|
+
{
|
|
925
|
+
if (e.type === 'keydown' && (e.key != ' ' && e.key != 'Enter'))
|
|
926
|
+
return;
|
|
927
|
+
|
|
928
|
+
if (getComputedStyle(_instance.element).pointerEvents === 'none')
|
|
929
|
+
return;
|
|
930
|
+
|
|
931
|
+
let ripple = _ripple.get(el);
|
|
932
|
+
clearTimeout(_rippleTimerId);
|
|
933
|
+
ripple.className = '';
|
|
934
|
+
|
|
935
|
+
setTimeout(function (el, e, ripple)
|
|
936
|
+
{
|
|
937
|
+
let pos = $lib.getPos(el, null, true);
|
|
938
|
+
|
|
939
|
+
if (!ripple.parentNode)
|
|
940
|
+
return;
|
|
941
|
+
|
|
942
|
+
ripple.parentNode.style.display = '';
|
|
943
|
+
ripple.style.top = ($lib.clientY(e) - pos.top) + 'px';
|
|
944
|
+
ripple.style.left = ($lib.clientX(e) - pos.left) + 'px';
|
|
945
|
+
ripple.addEventListener('animationend', function ()
|
|
946
|
+
{
|
|
947
|
+
_rippleTimerId = setTimeout(function ()
|
|
948
|
+
{
|
|
949
|
+
if (!_ripple)
|
|
950
|
+
return;
|
|
951
|
+
|
|
952
|
+
let ripple = _ripple.get(el);
|
|
953
|
+
|
|
954
|
+
if (ripple && ripple.parentNode)
|
|
955
|
+
ripple.parentNode.style.display = 'none';
|
|
956
|
+
}, 0);
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
ripple.className = _classOption.RIPPLE;
|
|
960
|
+
|
|
961
|
+
}.bind(this, el, e, ripple), 0);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function commandClick()
|
|
965
|
+
{
|
|
966
|
+
let returnValue = true,
|
|
967
|
+
expandable = (_instance.menuId || _instance.boxId || _instance.expandCommand);
|
|
968
|
+
|
|
969
|
+
if (_instance.disabled)
|
|
970
|
+
return false;
|
|
971
|
+
|
|
972
|
+
if (_instance.command)
|
|
973
|
+
returnValue = _instance.command();
|
|
974
|
+
else if (!_instance.split && expandable)
|
|
975
|
+
returnValue = toggleExpand(); // expand action witout command
|
|
976
|
+
|
|
977
|
+
if (returnValue === false)
|
|
978
|
+
return false;
|
|
979
|
+
|
|
980
|
+
_instance.events.onCommandClick.fire(_instance, createEventArgs());
|
|
981
|
+
|
|
982
|
+
if (_instance.autoPostBack)
|
|
983
|
+
_instance.postBack();
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function toggleExpand()
|
|
987
|
+
{
|
|
988
|
+
let returnValue = true;
|
|
989
|
+
|
|
990
|
+
if (_instance.disabled)
|
|
991
|
+
return;
|
|
992
|
+
|
|
993
|
+
if (_instance.expanded && _instance.collapseCommand)
|
|
994
|
+
returnValue = _instance.collapseCommand();
|
|
995
|
+
else if (!_instance.expanded && _instance.expandCommand)
|
|
996
|
+
returnValue = _instance.expandCommand();
|
|
997
|
+
|
|
998
|
+
if (!$lib.isEmpty(returnValue) && returnValue == false)
|
|
999
|
+
return false;
|
|
1000
|
+
|
|
1001
|
+
if (_instance.menuId || _instance.boxId)
|
|
1002
|
+
expandWidget(); // toggle action
|
|
1003
|
+
|
|
1004
|
+
_instance.expanded = !_instance.expanded;
|
|
1005
|
+
_instance.events.onExpandClick.fire(_instance, createEventArgs());
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function toggleSelect()
|
|
1009
|
+
{
|
|
1010
|
+
if (!_instance.selected)
|
|
1011
|
+
select();
|
|
1012
|
+
else if (_instance.type == _typeOption.CHECKBUTTON)
|
|
1013
|
+
deselect();
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
function select()
|
|
1017
|
+
{
|
|
1018
|
+
if (_instance.disabled || _instance.selected)
|
|
1019
|
+
return;
|
|
1020
|
+
|
|
1021
|
+
let element = (!_instance.split) ? _instance.element : _instance.element.firstElementChild;
|
|
1022
|
+
|
|
1023
|
+
if (_instance.type == _typeOption.RADIOBUTTON)
|
|
1024
|
+
{
|
|
1025
|
+
if (componyx.UI.Button.RadioGroups[_instance.radioGroupId])
|
|
1026
|
+
componyx.UI.Button.RadioGroups[_instance.radioGroupId].deselect();
|
|
1027
|
+
|
|
1028
|
+
componyx.UI.Button.RadioGroups[_instance.radioGroupId] = _instance;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
_instance.selected = true;
|
|
1032
|
+
element.classList.add('selected');
|
|
1033
|
+
_instance.events.onSelect.fire(_instance, createEventArgs());
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
function deselect()
|
|
1037
|
+
{
|
|
1038
|
+
if (_instance.disabled || !_instance.selected)
|
|
1039
|
+
return;
|
|
1040
|
+
|
|
1041
|
+
let element = (!_instance.split) ? _instance.element : _instance.element.firstElementChild;
|
|
1042
|
+
|
|
1043
|
+
if (_instance.type == _typeOption.RADIOBUTTON && _instance.radioGroupId)
|
|
1044
|
+
delete componyx.UI.Button.RadioGroups[_instance.radioGroupId];
|
|
1045
|
+
|
|
1046
|
+
_instance.selected = false;
|
|
1047
|
+
element.classList.remove('selected');
|
|
1048
|
+
_instance.events.onDeselect.fire(_instance, createEventArgs());
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
function enable()
|
|
1052
|
+
{
|
|
1053
|
+
let button = _instance.element;
|
|
1054
|
+
|
|
1055
|
+
_instance.disabled = false;
|
|
1056
|
+
button.classList.remove('disabled');
|
|
1057
|
+
setTabIndex(_instance.tabIndex);
|
|
1058
|
+
|
|
1059
|
+
if (_handlers.length == 0)
|
|
1060
|
+
bindGlobalEvents(button, _divCommand, _divExpand);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function disable(keepSelected)
|
|
1064
|
+
{
|
|
1065
|
+
if (_instance.selected && !keepSelected)
|
|
1066
|
+
deselect();
|
|
1067
|
+
|
|
1068
|
+
_instance.disabled = true;
|
|
1069
|
+
_instance.element.classList.add('disabled');
|
|
1070
|
+
setTabIndex(-1);
|
|
1071
|
+
unbindEvents();
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function setTabIndex(tabIndex)
|
|
1075
|
+
{
|
|
1076
|
+
const index = Number(tabIndex) || 0;
|
|
1077
|
+
_instance.element.setAttribute('tabindex', index);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function getAlignment(align, def)
|
|
1081
|
+
{
|
|
1082
|
+
align = ($lib.isEmpty(align)) ? (def) ? def : _alignOption.CENTER : align;
|
|
1083
|
+
return _alignOption.getName(align)
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
function focus()
|
|
1087
|
+
{
|
|
1088
|
+
blur();
|
|
1089
|
+
|
|
1090
|
+
if (_instance.split)
|
|
1091
|
+
_divCommand.focus();
|
|
1092
|
+
else
|
|
1093
|
+
_instance.element.focus();
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
function blur()
|
|
1097
|
+
{
|
|
1098
|
+
if (_instance.split)
|
|
1099
|
+
{
|
|
1100
|
+
_divCommand.blur();
|
|
1101
|
+
_divExpand.blur();
|
|
1102
|
+
}
|
|
1103
|
+
else
|
|
1104
|
+
_instance.element.blur();
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function expandWidget()
|
|
1108
|
+
{
|
|
1109
|
+
if (_instance.menuId)
|
|
1110
|
+
expandMenu();
|
|
1111
|
+
else
|
|
1112
|
+
expandBox();
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
function expandMenu()
|
|
1116
|
+
{
|
|
1117
|
+
let menu = $UI.store[_instance.menuId],
|
|
1118
|
+
isKeyboardNavigation = _instance.isKeyboardNavigation();
|
|
1119
|
+
|
|
1120
|
+
menu.rootExpandDirection = ($lib.isEmpty(_instance.expandDirection)) ? _expandDirectionOption.DOWN : _instance.expandDirection;
|
|
1121
|
+
menu.events.onLastItemCollapseComplete.priorityAdd(() => { _instance.expanded = false; }, null, true);
|
|
1122
|
+
menu.events.onItemExpandComplete.priorityAdd(() =>
|
|
1123
|
+
{
|
|
1124
|
+
_instance.expanded = true;
|
|
1125
|
+
|
|
1126
|
+
if (isKeyboardNavigation)
|
|
1127
|
+
setTimeout(() => { menu.element.focus(); });
|
|
1128
|
+
|
|
1129
|
+
}, null, true);
|
|
1130
|
+
|
|
1131
|
+
menu.expand(_instance.menuItemId, _instance.element, true);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function expandBox()
|
|
1135
|
+
{
|
|
1136
|
+
let box = $UI.store[_instance.boxId];
|
|
1137
|
+
box.expander = _instance.element;
|
|
1138
|
+
box.expandDirection = ($lib.isEmpty(_instance.expandDirection)) ? _expandDirectionOption.DOWN : _instance.expandDirection;
|
|
1139
|
+
box.autoPosition = componyx.UI.Box.AutoPositionOption.EXPAND;
|
|
1140
|
+
|
|
1141
|
+
box.events.onHideComplete.priorityAdd(() => { _instance.expanded = false; }, null, true);
|
|
1142
|
+
box.toggle();
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function dispose()
|
|
1146
|
+
{
|
|
1147
|
+
let groups = componyx.UI.Button.RadioGroups;
|
|
1148
|
+
|
|
1149
|
+
if (groups[_instance.radioGroupId] === _instance)
|
|
1150
|
+
delete groups[_instance.radioGroupId];
|
|
1151
|
+
|
|
1152
|
+
_instance.split = false;
|
|
1153
|
+
_anchor = null;
|
|
1154
|
+
_ripple = new Map();
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* @see {@link componyx.UI.base.methods}
|
|
1160
|
+
*/
|
|
1161
|
+
componyx.UI.Button.prototype = Object.create($base.methods);
|
|
1162
|
+
componyx.UI.Button.prototype.constructor = componyx.UI.Button;
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* RadioGroups
|
|
1166
|
+
* @type {object.<string, string>}
|
|
1167
|
+
* @readonly
|
|
1168
|
+
*/
|
|
1169
|
+
componyx.UI.Button.RadioGroups = {};
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* A singleton ShortcutManager attached to the Button class.
|
|
1173
|
+
* Manages registration and dispatch of keyboard shortcuts (Ctrl on Windows, ⌘ on Mac).
|
|
1174
|
+
* Buttons register/unregister themselves by key combo and optional scope element.
|
|
1175
|
+
* @namespace componyx.UI.Button.ShortcutManager
|
|
1176
|
+
* @ignore
|
|
1177
|
+
*/
|
|
1178
|
+
componyx.UI.Button.ShortcutManager = (() =>
|
|
1179
|
+
{
|
|
1180
|
+
const shortcutButtons = new Map(),
|
|
1181
|
+
isMac = navigator.userAgent.toLowerCase().includes('Mac');
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Build a normalized key combo string from a KeyboardEvent.
|
|
1185
|
+
* E.g. "ctrl+z", "ctrl+shift+s", "alt+f".
|
|
1186
|
+
* @param {KeyboardEvent} e
|
|
1187
|
+
* @returns {string}
|
|
1188
|
+
* @ignore
|
|
1189
|
+
*/
|
|
1190
|
+
function getKeyCombo(e)
|
|
1191
|
+
{
|
|
1192
|
+
const parts = [];
|
|
1193
|
+
if (e.ctrlKey || (isMac && e.metaKey)) parts.push('ctrl');
|
|
1194
|
+
if (e.altKey) parts.push('alt');
|
|
1195
|
+
if (e.shiftKey) parts.push('shift');
|
|
1196
|
+
|
|
1197
|
+
if (e.key)
|
|
1198
|
+
parts.push(e.key.toLowerCase());
|
|
1199
|
+
|
|
1200
|
+
return parts.join('+');
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* Global keydown handler that dispatches to the first matching button.
|
|
1205
|
+
* @param {KeyboardEvent} e
|
|
1206
|
+
* @ignore
|
|
1207
|
+
*/
|
|
1208
|
+
function keydown(e)
|
|
1209
|
+
{
|
|
1210
|
+
const key = getKeyCombo(e),
|
|
1211
|
+
buttons = shortcutButtons.get(key);
|
|
1212
|
+
|
|
1213
|
+
if (!buttons)
|
|
1214
|
+
return;
|
|
1215
|
+
|
|
1216
|
+
const button = getActiveButton(buttons, e);
|
|
1217
|
+
|
|
1218
|
+
if (button)
|
|
1219
|
+
{
|
|
1220
|
+
button.commandClick();
|
|
1221
|
+
e.preventDefault();
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
function getActiveButton(buttons, e)
|
|
1226
|
+
{
|
|
1227
|
+
const doc = e.target?.ownerDocument || document,
|
|
1228
|
+
activeEl = doc.activeElement;
|
|
1229
|
+
|
|
1230
|
+
for (const btn of buttons)
|
|
1231
|
+
{
|
|
1232
|
+
const scopeEl = getScopedElement(btn);
|
|
1233
|
+
|
|
1234
|
+
if (scopeEl === activeEl) return btn;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// Otherwise, traverse up from activeElement
|
|
1238
|
+
let el = activeEl;
|
|
1239
|
+
while (el)
|
|
1240
|
+
{
|
|
1241
|
+
for (const btn of buttons)
|
|
1242
|
+
{
|
|
1243
|
+
const scopeEl = getScopedElement(btn);
|
|
1244
|
+
|
|
1245
|
+
if (scopeEl && scopeEl.contains(el)) return btn;
|
|
1246
|
+
}
|
|
1247
|
+
el = el.parentElement;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
return null; // no matching button
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function getScopedElement(button)
|
|
1254
|
+
{
|
|
1255
|
+
const scope = button.shortcutScope,
|
|
1256
|
+
scopeEl = (typeof scope === 'function') ? scope() :
|
|
1257
|
+
(typeof scope === 'string') ? $lib('#' + scope) : scope;
|
|
1258
|
+
|
|
1259
|
+
return scopeEl;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
return {
|
|
1263
|
+
/**
|
|
1264
|
+
* Register a Button instance for its key combo.
|
|
1265
|
+
* @param {componyx.UI.Button} button The Button to register in the ShortcutManager.
|
|
1266
|
+
* @ignore
|
|
1267
|
+
*/
|
|
1268
|
+
registerButton(button)
|
|
1269
|
+
{
|
|
1270
|
+
if (!button.shortcutKey)
|
|
1271
|
+
return;
|
|
1272
|
+
|
|
1273
|
+
let key = button.shortcutKey.toLowerCase(),
|
|
1274
|
+
doc = button.element.ownerDocument;
|
|
1275
|
+
|
|
1276
|
+
if (!/^(ctrl|alt|shift)\+/.test(key))
|
|
1277
|
+
key = 'ctrl+' + key;
|
|
1278
|
+
|
|
1279
|
+
if (!shortcutButtons.has(key))
|
|
1280
|
+
shortcutButtons.set(key, new Set());
|
|
1281
|
+
|
|
1282
|
+
shortcutButtons.get(key).add(button);
|
|
1283
|
+
|
|
1284
|
+
if (!$lib.has(doc, 'keydown', keydown))
|
|
1285
|
+
$lib.on(doc, 'keydown', keydown);
|
|
1286
|
+
},
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Unregister a Button instance, removing its shortcut.
|
|
1290
|
+
* @param {componyx.UI.Button} button The Button to register in the ShortcutManager.
|
|
1291
|
+
* @ignore
|
|
1292
|
+
*/
|
|
1293
|
+
unregisterButton(button)
|
|
1294
|
+
{
|
|
1295
|
+
if (!button.key)
|
|
1296
|
+
return;
|
|
1297
|
+
|
|
1298
|
+
let key = button.shortcutKey.toLowerCase(),
|
|
1299
|
+
doc = button.element.ownerDocument;
|
|
1300
|
+
|
|
1301
|
+
if (!/^(ctrl|alt|shift)\+/.test(key))
|
|
1302
|
+
key = 'ctrl+' + key;
|
|
1303
|
+
|
|
1304
|
+
shortcutButtons.get(key)?.delete(button);
|
|
1305
|
+
|
|
1306
|
+
if (shortcutButtons.size === 0)
|
|
1307
|
+
$lib.off(doc, 'keydown', keydown);
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
})();
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* Gets the selected button for the specified radio group.
|
|
1316
|
+
* @name componyx.UI.Button#getSelected
|
|
1317
|
+
* @static
|
|
1318
|
+
* @function
|
|
1319
|
+
*/
|
|
1320
|
+
componyx.UI.Button.getSelected = function (radioGroupId)
|
|
1321
|
+
{
|
|
1322
|
+
return componyx.UI.Button.RadioGroups[radioGroupId];
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* SizeOption
|
|
1327
|
+
* @readonly
|
|
1328
|
+
* @enum {string}
|
|
1329
|
+
*/
|
|
1330
|
+
componyx.UI.Button.SizeOption =
|
|
1331
|
+
{
|
|
1332
|
+
SMALL: 's',
|
|
1333
|
+
MEDIUM: 'm',
|
|
1334
|
+
LARGE: 'l',
|
|
1335
|
+
XLARGE: 'xl'
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* TypeOption
|
|
1340
|
+
* @readonly
|
|
1341
|
+
* @enum {number}
|
|
1342
|
+
*/
|
|
1343
|
+
componyx.UI.Button.TypeOption =
|
|
1344
|
+
{
|
|
1345
|
+
COMMANDBUTTON: 0,
|
|
1346
|
+
CHECKBUTTON: 1,
|
|
1347
|
+
RADIOBUTTON: 2
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* ExpandDirectionOption
|
|
1352
|
+
* @readonly
|
|
1353
|
+
* @enum {number}
|
|
1354
|
+
*/
|
|
1355
|
+
componyx.UI.Button.ExpandDirectionOption =
|
|
1356
|
+
{
|
|
1357
|
+
DOWN: 0,
|
|
1358
|
+
RIGHT: 1,
|
|
1359
|
+
UP: 2,
|
|
1360
|
+
LEFT: 3,
|
|
1361
|
+
|
|
1362
|
+
getName: function (value) { return $base.static.getKeyByValue(this, value).toLowerCase(); }
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* AlignOption
|
|
1367
|
+
* @readonly
|
|
1368
|
+
* @enum {number}
|
|
1369
|
+
*/
|
|
1370
|
+
componyx.UI.Button.AlignOption =
|
|
1371
|
+
{
|
|
1372
|
+
LEFT: 0,
|
|
1373
|
+
CENTER: 1,
|
|
1374
|
+
RIGHT: 2,
|
|
1375
|
+
|
|
1376
|
+
getName: function (value) { return $base.static.getKeyByValue(this, value).toLowerCase(); }
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* DecorationOption
|
|
1381
|
+
* @readonly
|
|
1382
|
+
* @enum {number}
|
|
1383
|
+
*/
|
|
1384
|
+
componyx.UI.Button.DecorationOption =
|
|
1385
|
+
{
|
|
1386
|
+
BACKGROUND: 0,
|
|
1387
|
+
UNDERLINE: 1,
|
|
1388
|
+
OVERLINE: 2,
|
|
1389
|
+
FRONTLINE: 3,
|
|
1390
|
+
BACKLINE: 4,
|
|
1391
|
+
|
|
1392
|
+
getName: function (value) { return $base.static.getKeyByValue(this, value).toLowerCase(); }
|
|
1393
|
+
};
|
|
1394
|
+
})();
|
|
1395
|
+
|
|
1396
|
+
const Button = componyx.UI.Button;
|
|
1397
|
+
|
|
1398
|
+
export { Button };
|