@componyx/ui 0.0.0-stage → 1.0.4
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/DataBinder.js +602 -0
- package/Form/Modules/DataObserver.js +717 -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
|
@@ -0,0 +1,607 @@
|
|
|
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
|
+
* Carousel 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.Carousel = function Carousel(id, properties)
|
|
18
|
+
{
|
|
19
|
+
// define private properties
|
|
20
|
+
var _instance = this,
|
|
21
|
+
_slider, _viewport, _navigation, _indicators, _drag, _select, _start = {}, _last = {}, _animation,
|
|
22
|
+
_selectedIndex, _prevIndex, _rotateTimerId, _itemCount, _defaultInterval = 5000, _allowDrag = true;
|
|
23
|
+
$base.static.ThemeOption;
|
|
24
|
+
var _classOption =
|
|
25
|
+
{
|
|
26
|
+
HORIZONTAL: 'horizontal',
|
|
27
|
+
DRAG: 'drag',
|
|
28
|
+
VIEWPORT: 'viewport',
|
|
29
|
+
SLIDER: 'slider',
|
|
30
|
+
NAVIGATION: 'navigation',
|
|
31
|
+
PREVIOUS: 'previous',
|
|
32
|
+
NEXT: 'next',
|
|
33
|
+
ITEM: 'item',
|
|
34
|
+
MOVEBACK: 'move-back',
|
|
35
|
+
MOVEFORWARD: 'move-forward',
|
|
36
|
+
MOVETO: 'move-to',
|
|
37
|
+
SELECTED: 'selected',
|
|
38
|
+
OUT_OF_VIEW: 'out-of-view'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// define public properties
|
|
42
|
+
/**
|
|
43
|
+
* Gets or sets a value indicating if the carousel is rendered horizontal.
|
|
44
|
+
* @type {Boolean}
|
|
45
|
+
*/
|
|
46
|
+
this.horizontal = false;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Gets or sets a value indicating if the carousel takes the full screen size.
|
|
50
|
+
* @type {Boolean}
|
|
51
|
+
*/
|
|
52
|
+
this.fullscreen = false;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Gets or sets a value indicating if items can be selected by dragging.
|
|
56
|
+
* @type {Boolean}
|
|
57
|
+
*/
|
|
58
|
+
this.dragNavigation = true;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Gets or sets a value indicating if items can be selected with the mouse wheel.
|
|
62
|
+
* @type {Boolean}
|
|
63
|
+
*/
|
|
64
|
+
this.wheelNavigation = true;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Gets or sets a value indicating if items can be selected with the keyboard.
|
|
68
|
+
* With the option horizontal enabled only the left/right arrow keys can be used.
|
|
69
|
+
* When rendered vertically the up/down arrows, page up/down, home (first item) and end (last item) keys can be used.
|
|
70
|
+
* @type {Boolean}
|
|
71
|
+
*/
|
|
72
|
+
this.keyboardNavigation = true;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Gets or sets a value indicating if there is a transition animation on initial item select.
|
|
76
|
+
* @type {Boolean}
|
|
77
|
+
*/
|
|
78
|
+
this.initialTransition = true;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Gets or sets the percentage of the item to be visible before the item is selected.
|
|
82
|
+
* @type {Number}
|
|
83
|
+
*/
|
|
84
|
+
this.dragRevealPercentage = 50;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Gets or sets the drag speed (moved pixels relative to the elapsed time) required to select the designated item when the reveal percentage has not been matched.
|
|
88
|
+
* @type {Number}
|
|
89
|
+
*/
|
|
90
|
+
this.dragSelectSpeed = 20;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Gets or sets the interval in milliseconds for automatic carousel rotation.
|
|
94
|
+
* @type {Number}
|
|
95
|
+
*/
|
|
96
|
+
this.rotateInterval = 0;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Gets or sets the initial selected item index.
|
|
100
|
+
* @type {Number}
|
|
101
|
+
*/
|
|
102
|
+
this.selectedIndex = 0;
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Carousel slide animation.
|
|
107
|
+
* @type animation
|
|
108
|
+
* @property {String} cssClass=slide-animation - Gets or sets the css class that is applied to the element to provide the slide animation/transition.
|
|
109
|
+
*/
|
|
110
|
+
this.animation =
|
|
111
|
+
{
|
|
112
|
+
cssClass: 'slide-animation'
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @class
|
|
117
|
+
* @augments componyx.UI.base.Events
|
|
118
|
+
* @memberof componyx.UI.Carousel
|
|
119
|
+
* @property {componyx.UI.base.Event} onItemSelect - Event which fires on an item select. @see {@link componyx.UI.Carousel.CarouselEventArgs}
|
|
120
|
+
* @property {componyx.UI.base.Event} onTransitionComplete - Event which fires when the item-select transition animation has completed. @see {@link componyx.UI.Carousel.CarouselEventArgs}
|
|
121
|
+
* @see {@link componyx.UI.base.Events}
|
|
122
|
+
*/
|
|
123
|
+
function CarouselEvents(events)
|
|
124
|
+
{
|
|
125
|
+
Object.assign(this, events);
|
|
126
|
+
|
|
127
|
+
this.onItemSelect = $base.static.createEvent('onItemSelect');
|
|
128
|
+
this.onTransitionComplete = $base.static.createEvent('onTransitionComplete');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Carousel events
|
|
132
|
+
* @type {componyx.UI.Carousel.CarouselEvents}
|
|
133
|
+
*/
|
|
134
|
+
this.events = new CarouselEvents(this.events);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Carousel event arguments.
|
|
138
|
+
* @typedef {Object} CarouselEventArgs
|
|
139
|
+
* @memberof componyx.UI.Carousel
|
|
140
|
+
* @property {Number} index - The index of the selected item.
|
|
141
|
+
* @property {Number} [previousIndex] - The index of the previously selected item (onItemSelect only; undefined on the first select).
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
// inherit base instance members
|
|
145
|
+
$base.Component.apply(this, [id, properties]);
|
|
146
|
+
|
|
147
|
+
this.stop = function ()
|
|
148
|
+
{
|
|
149
|
+
clearTimeout(_rotateTimerId);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Starts rotating the slide items automatically.
|
|
154
|
+
* @param {Number} [interval]=5000 The interval in milliseconds before moving to the next item.
|
|
155
|
+
*/
|
|
156
|
+
this.start = function (interval)
|
|
157
|
+
{
|
|
158
|
+
_instance.stop();
|
|
159
|
+
_instance.rotateInterval = interval || _defaultInterval;
|
|
160
|
+
_rotateTimerId = setTimeout(nextItem, _instance.rotateInterval);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Gets the index of the selected item.
|
|
165
|
+
* @returns {Number} The index of the selected item.
|
|
166
|
+
*/
|
|
167
|
+
this.getSelectedIndex = function ()
|
|
168
|
+
{
|
|
169
|
+
return _selectedIndex;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Selects the item with the specified index.
|
|
174
|
+
* @param {Number} index The index of the item.
|
|
175
|
+
* @param {Boolean} [instant] A value indicating if the item must be selected instantly (without transition animation).
|
|
176
|
+
*/
|
|
177
|
+
this.selectItem = function (index, instant)
|
|
178
|
+
{
|
|
179
|
+
selectItem(index, instant);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Renders the component
|
|
184
|
+
*/
|
|
185
|
+
this.render = function ()
|
|
186
|
+
{
|
|
187
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING)
|
|
188
|
+
{
|
|
189
|
+
// call base render and return
|
|
190
|
+
$base.methods.render.call(_instance, preRender, 'carousel', false);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// render logic after loading resources
|
|
195
|
+
draw();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Handles the post render procedure.
|
|
200
|
+
*/
|
|
201
|
+
this.postRender = function ()
|
|
202
|
+
{
|
|
203
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING) // extra safety to never execute a postRender when the component state is incorrect
|
|
204
|
+
return;
|
|
205
|
+
|
|
206
|
+
if (!$base.methods.postRender.call(_instance)) // component got destroyed on postrender event
|
|
207
|
+
return;
|
|
208
|
+
|
|
209
|
+
selectItem(0, true);
|
|
210
|
+
|
|
211
|
+
if (_instance.selectedIndex > 0)
|
|
212
|
+
selectItem(_instance.selectedIndex, _instance.initialTransition);
|
|
213
|
+
else
|
|
214
|
+
{
|
|
215
|
+
if (_instance.rotateInterval)
|
|
216
|
+
_instance.start(_instance.rotateInterval);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Destroys the component.
|
|
222
|
+
* @param {Boolean} keepEvents A value indicating if component events should be kept.
|
|
223
|
+
*/
|
|
224
|
+
this.destroy = function (keepEvents)
|
|
225
|
+
{
|
|
226
|
+
dispose();
|
|
227
|
+
$base.methods.destroy.call(this, keepEvents);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
function preRender()
|
|
231
|
+
{
|
|
232
|
+
// initialize script and css
|
|
233
|
+
return ['Carousel'];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function draw()
|
|
237
|
+
{
|
|
238
|
+
var index = -1,
|
|
239
|
+
horizontal = _instance.horizontal;
|
|
240
|
+
|
|
241
|
+
if (!_instance.fullscreen)
|
|
242
|
+
_instance.element.setAttribute('tabindex', 0);
|
|
243
|
+
|
|
244
|
+
if (horizontal)
|
|
245
|
+
$lib.addClass(_instance.element, _classOption.HORIZONTAL);
|
|
246
|
+
|
|
247
|
+
_viewport = $lib.element(_instance.element, null, '', null, { "class": _classOption.VIEWPORT });
|
|
248
|
+
_slider = $lib.element(_viewport, null, '', null, { "class": _classOption.SLIDER });
|
|
249
|
+
|
|
250
|
+
_navigation = $lib.element(_instance.element, null, '', null, { "class": _classOption.NAVIGATION });
|
|
251
|
+
createItem(_navigation, _classOption.PREVIOUS, 'div', prevItem);
|
|
252
|
+
|
|
253
|
+
_indicators = $lib.element(_navigation, null, 'ul');
|
|
254
|
+
|
|
255
|
+
_instance.templates.forEach(function (template, id)
|
|
256
|
+
{
|
|
257
|
+
var item = $lib.element(_slider, null, '', null, { 'class': `${_classOption.ITEM} ${_classOption.OUT_OF_VIEW}` });
|
|
258
|
+
|
|
259
|
+
if (!horizontal)
|
|
260
|
+
item.style.height = (100 / (_instance.templates.size)) + "%";
|
|
261
|
+
|
|
262
|
+
_instance.applyTemplate(item, id);
|
|
263
|
+
createItem(_indicators, _classOption.ITEM, 'li', selectItem.bind(_instance, ++index, null));
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
_itemCount = _instance.templates.size;
|
|
267
|
+
|
|
268
|
+
if (horizontal)
|
|
269
|
+
_slider.style.width = (_itemCount * 100) + '%';
|
|
270
|
+
else
|
|
271
|
+
_slider.style.height = (_itemCount * 100) + '%';
|
|
272
|
+
|
|
273
|
+
createItem(_navigation, _classOption.NEXT, 'div', nextItem);
|
|
274
|
+
bindEvents();
|
|
275
|
+
|
|
276
|
+
if (_instance.dragNavigation)
|
|
277
|
+
$lib.addClass(_instance.element, _classOption.DRAG);
|
|
278
|
+
|
|
279
|
+
_instance.postRender();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function createItem(container, cssClass, tag, fn)
|
|
283
|
+
{
|
|
284
|
+
var a = $lib.element($lib.element(container, null, tag, null, { 'class': cssClass }), null, 'a', null, { href: 'javascript:void(0);' });
|
|
285
|
+
$lib.on(a.parentElement, 'click', fn);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function bindEvents()
|
|
289
|
+
{
|
|
290
|
+
var doc = document,
|
|
291
|
+
el = (_instance.fullscreen) ? doc : _instance.element;
|
|
292
|
+
|
|
293
|
+
if (_instance.dragNavigation)
|
|
294
|
+
$lib.on(el, 'mousedown', startDrag);
|
|
295
|
+
|
|
296
|
+
$lib.on(doc, 'mousemove', drag);
|
|
297
|
+
$lib.on(doc, 'mouseup', endDrag);
|
|
298
|
+
$lib.on(window, 'resize', resize);
|
|
299
|
+
|
|
300
|
+
if (_instance.keyboardNavigation)
|
|
301
|
+
$lib.on(el, 'keydown', key);
|
|
302
|
+
|
|
303
|
+
if (_instance.wheelNavigation)
|
|
304
|
+
$lib.on(el, 'wheel', wheel);
|
|
305
|
+
|
|
306
|
+
$lib.on(_navigation, 'mousedown', cancelDrag);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function resize()
|
|
310
|
+
{
|
|
311
|
+
$lib.defer(function () { selectItem(_selectedIndex, true); });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function cancelDrag()
|
|
315
|
+
{
|
|
316
|
+
_allowDrag = false;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function prevItem()
|
|
320
|
+
{
|
|
321
|
+
selectItem(_selectedIndex - 1);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function nextItem()
|
|
325
|
+
{
|
|
326
|
+
selectItem(_selectedIndex + 1);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function key(e)
|
|
330
|
+
{
|
|
331
|
+
var keyCode = e.key,
|
|
332
|
+
find = ' ' + keyCode.toString() + ' ',
|
|
333
|
+
horizontal = _instance.horizontal, index;
|
|
334
|
+
|
|
335
|
+
if ((horizontal && ' ArrowLeft ArrowRight '.indexOf(find) == -1) ||
|
|
336
|
+
(!horizontal && ' PageUp PageDown Home End ArrowUp ArrowDown '.indexOf(find) == -1))
|
|
337
|
+
return;
|
|
338
|
+
|
|
339
|
+
if (keyCode == 'End')
|
|
340
|
+
index = _itemCount - 1;
|
|
341
|
+
else if (keyCode == 'Home')
|
|
342
|
+
index = 0;
|
|
343
|
+
else
|
|
344
|
+
index = (' PageUp ArrowUp ArrowLeft '.indexOf(find) > -1) ? _selectedIndex - 1 : _selectedIndex + 1;
|
|
345
|
+
|
|
346
|
+
selectItem(index);
|
|
347
|
+
|
|
348
|
+
if (!_instance.fullscreen)
|
|
349
|
+
e.preventDefault();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function wheel(e)
|
|
353
|
+
{
|
|
354
|
+
var forwards = (e.deltaY > 0);
|
|
355
|
+
|
|
356
|
+
if ((forwards && _selectedIndex == _itemCount - 1) || !forwards && !_selectedIndex)
|
|
357
|
+
return;
|
|
358
|
+
|
|
359
|
+
selectItem((forwards) ? _selectedIndex + 1 : _selectedIndex - 1);
|
|
360
|
+
|
|
361
|
+
if (!_instance.fullscreen)
|
|
362
|
+
e.preventDefault();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function startDrag(e)
|
|
366
|
+
{
|
|
367
|
+
if (_drag || !_allowDrag)
|
|
368
|
+
return;
|
|
369
|
+
|
|
370
|
+
let prop = (_instance.horizontal) ? 'left' : 'top',
|
|
371
|
+
items = $lib(_classOption.ITEM, _slider);
|
|
372
|
+
|
|
373
|
+
_drag = true;
|
|
374
|
+
_start.x = $lib.clientX(e);
|
|
375
|
+
_start.y = $lib.clientY(e);
|
|
376
|
+
_start.width = _instance.element.offsetWidth;
|
|
377
|
+
_start.height = _instance.element.offsetHeight;
|
|
378
|
+
_start.left = parseFloat(_slider.style.left) || 0;
|
|
379
|
+
_start.top = parseFloat(_slider.style.top) || 0;
|
|
380
|
+
_start.time = new Date().getTime();
|
|
381
|
+
_last = {};
|
|
382
|
+
|
|
383
|
+
if (_select)
|
|
384
|
+
{
|
|
385
|
+
var pos = $lib.styleValue(_slider, prop, true),
|
|
386
|
+
stepSize = (_instance.horizontal) ? _instance.element.offsetWidth : _instance.element.offsetHeight,
|
|
387
|
+
nearestIndex = Math.round(-parseFloat(pos) / stepSize);
|
|
388
|
+
|
|
389
|
+
nearestIndex = Math.max(0, Math.min(_itemCount - 1, nearestIndex));
|
|
390
|
+
|
|
391
|
+
stopAnimation(); // animation stop will set viewport position to selectedIndex
|
|
392
|
+
selectItem(nearestIndex, true); // snap state (index, nav, out-of-view) to match the interrupted position
|
|
393
|
+
|
|
394
|
+
_slider.style[prop] = pos;
|
|
395
|
+
_start[prop] = parseFloat(pos) || 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++)
|
|
399
|
+
$lib.removeClass(items[itemIndex], _classOption.OUT_OF_VIEW);
|
|
400
|
+
|
|
401
|
+
drag(e);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function drag(e)
|
|
405
|
+
{
|
|
406
|
+
if (!_drag)
|
|
407
|
+
return;
|
|
408
|
+
|
|
409
|
+
let horizontal = _instance.horizontal,
|
|
410
|
+
x = $lib.clientX(e),
|
|
411
|
+
y = $lib.clientY(e),
|
|
412
|
+
moveX = _start.x - x,
|
|
413
|
+
moveY = _start.y - y,
|
|
414
|
+
move = (horizontal) ? moveX : moveY,
|
|
415
|
+
forwards = move > 0;
|
|
416
|
+
|
|
417
|
+
if (!move || (forwards && _selectedIndex == _itemCount - 1) || !forwards && !_selectedIndex)
|
|
418
|
+
return;
|
|
419
|
+
|
|
420
|
+
_instance.stop();
|
|
421
|
+
|
|
422
|
+
if (horizontal)
|
|
423
|
+
_slider.style.left = $lib.unit(_start.left - moveX);
|
|
424
|
+
else
|
|
425
|
+
_slider.style.top = $lib.unit(_start.top - moveY);
|
|
426
|
+
|
|
427
|
+
_last.x = x;
|
|
428
|
+
_last.moveX = moveX;
|
|
429
|
+
_last.y = y;
|
|
430
|
+
_last.moveY = moveY;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function endDrag(e)
|
|
434
|
+
{
|
|
435
|
+
if (!_allowDrag)
|
|
436
|
+
{
|
|
437
|
+
_allowDrag = true;
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (!_drag)
|
|
442
|
+
return;
|
|
443
|
+
|
|
444
|
+
var horizontal = _instance.horizontal,
|
|
445
|
+
percentage = (_instance.dragRevealPercentage / 100) || 0.5;
|
|
446
|
+
(_instance.dragSelectSpeed / 100) || 0.2;
|
|
447
|
+
var isSlide = ((horizontal && Math.abs(_last.moveX) / _start.width >= percentage) || (!horizontal && Math.abs(_last.moveY) / _start.height >= percentage)),
|
|
448
|
+
move = (horizontal) ? _last.moveX : _last.moveY,
|
|
449
|
+
forwards = move > 0,
|
|
450
|
+
elapsedTime;
|
|
451
|
+
|
|
452
|
+
if (!isSlide)
|
|
453
|
+
{
|
|
454
|
+
elapsedTime = new Date().getTime() - _start.time;
|
|
455
|
+
isSlide = (Math.abs(move) / elapsedTime >= 0.20); // 1px per 5ms
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
_drag = _select = false;
|
|
459
|
+
|
|
460
|
+
if (isSlide)
|
|
461
|
+
selectItem((forwards) ? _selectedIndex + 1 : _selectedIndex - 1);
|
|
462
|
+
else
|
|
463
|
+
selectItem(_selectedIndex); // slide back to current
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function selectItem(index, instant)
|
|
467
|
+
{
|
|
468
|
+
var moveIndicator = true;
|
|
469
|
+
|
|
470
|
+
if (index >= _itemCount)
|
|
471
|
+
{
|
|
472
|
+
moveIndicator = false;
|
|
473
|
+
index = 0;
|
|
474
|
+
}
|
|
475
|
+
else if (index < 0)
|
|
476
|
+
{
|
|
477
|
+
moveIndicator = false;
|
|
478
|
+
index = _itemCount - 1;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let a = _instance.animation,
|
|
482
|
+
horizontal = _instance.horizontal,
|
|
483
|
+
prop = (horizontal) ? 'left' : 'top';
|
|
484
|
+
$base.static.AnimationEasingOption.getName(a.easing) || $base.static.AnimationEasingOption.getName($base.static.AnimationEasingOption.easeOutCubic);
|
|
485
|
+
let to = (horizontal) ? (index * _instance.element.offsetWidth) : (index * _instance.element.offsetHeight),
|
|
486
|
+
nav = $lib(null, _indicators, 'li'),
|
|
487
|
+
items = $lib(_classOption.ITEM, _slider);
|
|
488
|
+
|
|
489
|
+
_instance.stop();
|
|
490
|
+
stopAnimation();
|
|
491
|
+
|
|
492
|
+
_prevIndex = _selectedIndex;
|
|
493
|
+
_selectedIndex = index;
|
|
494
|
+
_select = true;
|
|
495
|
+
|
|
496
|
+
if ($lib.isEmpty(_slider.style[prop]))
|
|
497
|
+
{
|
|
498
|
+
_slider.style[prop] = '0px'; // must have a value to get transitionend event
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (!instant)
|
|
502
|
+
{
|
|
503
|
+
var value = $lib.unit(to * -1);
|
|
504
|
+
|
|
505
|
+
if (_slider.style[prop] != value)
|
|
506
|
+
{
|
|
507
|
+
_animation = $lib.cssAnimation(_slider, a.cssClass || undefined, [], { onComplete: transitionComplete });
|
|
508
|
+
_slider.style[prop] = value;
|
|
509
|
+
}
|
|
510
|
+
else
|
|
511
|
+
transitionComplete();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (_prevIndex != _selectedIndex)
|
|
515
|
+
{
|
|
516
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++)
|
|
517
|
+
$lib.removeClass(items[itemIndex], _classOption.OUT_OF_VIEW);
|
|
518
|
+
|
|
519
|
+
$lib.removeClass(nav[_prevIndex], _classOption.SELECTED);
|
|
520
|
+
|
|
521
|
+
if (!$lib.isEmpty(_prevIndex) && moveIndicator && Math.abs(_prevIndex - _selectedIndex) == 1)
|
|
522
|
+
$lib.addClass(nav[_prevIndex], (_prevIndex < _selectedIndex) ? _classOption.MOVEFORWARD : _classOption.MOVEBACK);
|
|
523
|
+
|
|
524
|
+
$lib.addClass(nav[_selectedIndex], _classOption.MOVETO);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
_instance.events.onItemSelect.fire(_instance, { index: _selectedIndex, previousIndex: _prevIndex });
|
|
528
|
+
|
|
529
|
+
if (instant)
|
|
530
|
+
transitionComplete();
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function stopAnimation()
|
|
534
|
+
{
|
|
535
|
+
if (_animation)
|
|
536
|
+
_animation.complete();
|
|
537
|
+
else if ($lib.hasClass(_slider, _instance.animation.cssClass)) // check for css animation
|
|
538
|
+
transitionComplete();
|
|
539
|
+
|
|
540
|
+
_animation = null;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function transitionComplete()
|
|
544
|
+
{
|
|
545
|
+
let prop = (_instance.horizontal) ? 'left' : 'top',
|
|
546
|
+
to = (_instance.horizontal) ? (_selectedIndex * _instance.element.offsetWidth) : (_selectedIndex * _instance.element.offsetHeight),
|
|
547
|
+
items = $lib(_classOption.ITEM, _slider),
|
|
548
|
+
nav = $lib(null, _indicators, 'li');
|
|
549
|
+
|
|
550
|
+
_slider.style[prop] = $lib.unit(to * -1);
|
|
551
|
+
|
|
552
|
+
$lib.off(_slider, 'transitionend animationend', transitionComplete);
|
|
553
|
+
$lib.removeClass(_slider, _instance.animation.cssClass);
|
|
554
|
+
|
|
555
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++)
|
|
556
|
+
{
|
|
557
|
+
if (itemIndex !== _selectedIndex)
|
|
558
|
+
$lib.addClass(items[itemIndex], _classOption.OUT_OF_VIEW);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
$lib.removeClass(nav[_prevIndex], _classOption.MOVEBACK + ' ' + _classOption.MOVEFORWARD);
|
|
562
|
+
$lib.removeClass(nav[_selectedIndex], _classOption.MOVETO);
|
|
563
|
+
$lib.addClass(nav[_selectedIndex], _classOption.SELECTED);
|
|
564
|
+
|
|
565
|
+
_animation = null;
|
|
566
|
+
_select = false;
|
|
567
|
+
|
|
568
|
+
if (_instance.rotateInterval)
|
|
569
|
+
_instance.start(_instance.rotateInterval);
|
|
570
|
+
|
|
571
|
+
_instance.events.onTransitionComplete.fire(_instance, { index: _selectedIndex });
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function dispose()
|
|
575
|
+
{
|
|
576
|
+
var doc = document;
|
|
577
|
+
|
|
578
|
+
stopAnimation();
|
|
579
|
+
_instance.stop();
|
|
580
|
+
|
|
581
|
+
if (_instance.fullscreen)
|
|
582
|
+
{
|
|
583
|
+
$lib.off(doc, 'mousedown', startDrag);
|
|
584
|
+
$lib.off(doc, 'keydown', key);
|
|
585
|
+
$lib.off(doc, 'wheel', wheel);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
$lib.off(doc, 'mousemove', drag);
|
|
589
|
+
$lib.off(doc, 'mouseup', endDrag);
|
|
590
|
+
$lib.off(window, 'resize', resize);
|
|
591
|
+
|
|
592
|
+
_last = {};
|
|
593
|
+
_select = _drag = false;
|
|
594
|
+
_selectedIndex = _prevIndex = undefined;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* @see {@link componyx.UI.base.methods}
|
|
600
|
+
*/
|
|
601
|
+
componyx.UI.Carousel.prototype = Object.create($base.methods);
|
|
602
|
+
componyx.UI.Carousel.prototype.constructor = componyx.UI.Carousel;
|
|
603
|
+
})(window);
|
|
604
|
+
|
|
605
|
+
const Carousel = componyx.UI.Carousel;
|
|
606
|
+
|
|
607
|
+
export { Carousel };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
.color-button.theme
|
|
3
|
+
{
|
|
4
|
+
display: inline-block;
|
|
5
|
+
line-height: normal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.color-button.theme .button.theme
|
|
9
|
+
{
|
|
10
|
+
padding: 4px;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
width: auto;
|
|
13
|
+
height: auto;
|
|
14
|
+
line-height: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.color-button.theme .button.theme div.color-box
|
|
18
|
+
{
|
|
19
|
+
position: relative;
|
|
20
|
+
width: 16px;
|
|
21
|
+
height: 16px;
|
|
22
|
+
border-style: none;
|
|
23
|
+
|
|
24
|
+
background: linear-gradient(45deg, rgba(0,0,0,0.0980392) 25%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 75%, rgba(0,0,0,0.0980392) 75%, rgba(0,0,0,0.0980392) 0),
|
|
25
|
+
linear-gradient(45deg, rgba(0,0,0,0.0980392) 25%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 75%, rgba(0,0,0,0.0980392) 75%, rgba(0,0,0,0.0980392) 0), rgb(255, 255, 255);
|
|
26
|
+
|
|
27
|
+
background-position: 0 0, 5px 5px;
|
|
28
|
+
background-size: 10px 10px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.color-button.theme .button.theme div.color-box > div
|
|
32
|
+
{
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0px;
|
|
35
|
+
right: 0px;
|
|
36
|
+
bottom: 0px;
|
|
37
|
+
left: 0px;
|
|
38
|
+
border-style: solid;
|
|
39
|
+
}
|