@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,674 @@
|
|
|
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
|
+
import '../Button/Button.js';
|
|
5
|
+
import '../NumericBox/NumericBox.js';
|
|
6
|
+
|
|
7
|
+
(function (window)
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* DataPager class.
|
|
11
|
+
* @class
|
|
12
|
+
* @memberof componyx.UI
|
|
13
|
+
* @augments componyx.UI.base.Component
|
|
14
|
+
* @mixes componyx.UI.base.methods
|
|
15
|
+
* @param {String} id The id of the component.
|
|
16
|
+
* @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
|
|
17
|
+
* @returns {Object} An instance of the component.
|
|
18
|
+
*/
|
|
19
|
+
componyx.UI.DataPager = function DataPager(id, properties)
|
|
20
|
+
{
|
|
21
|
+
// define private properties
|
|
22
|
+
var _instance = this,
|
|
23
|
+
_pageIndex = 1,
|
|
24
|
+
_renderCount = 0,
|
|
25
|
+
_renderedCount = 0,
|
|
26
|
+
_fireChange = true,
|
|
27
|
+
_hidden;
|
|
28
|
+
$base.static.ThemeOption;
|
|
29
|
+
|
|
30
|
+
var _classOption =
|
|
31
|
+
{
|
|
32
|
+
DATAPAGER: 'data-pager',
|
|
33
|
+
BUTTONFIRST: 'button first',
|
|
34
|
+
BUTTONLAST: 'button last',
|
|
35
|
+
BUTTONPREVIOUS: 'button prev',
|
|
36
|
+
BUTTONNEXT: 'button next',
|
|
37
|
+
BUTTONPREVIOUSGROUP: 'button prev-group',
|
|
38
|
+
BUTTONNEXTGROUP: 'button next-group',
|
|
39
|
+
BUTTONPAGE: 'button page',
|
|
40
|
+
PAGEHOLDER: 'page-holder'
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
_buttonOption =
|
|
44
|
+
{
|
|
45
|
+
FIRST: -1,
|
|
46
|
+
LAST: -2,
|
|
47
|
+
PREVIOUS: -3,
|
|
48
|
+
NEXT: -4,
|
|
49
|
+
PREVIOUSGROUP: -5,
|
|
50
|
+
NEXTGROUP: -6
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// define public properties
|
|
54
|
+
/**
|
|
55
|
+
* Gets or sets the css class of the button container.
|
|
56
|
+
* @type {String}
|
|
57
|
+
*/
|
|
58
|
+
this.cssClassButtonHolder = '';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Gets or sets the css class of the info container.
|
|
62
|
+
* @type {String}
|
|
63
|
+
*/
|
|
64
|
+
this.cssClassInfoHolder = '';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Gets or sets the css class of the page container.
|
|
68
|
+
* @type {String}
|
|
69
|
+
*/
|
|
70
|
+
this.cssClassPageHolder = '';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets or sets the item count.
|
|
74
|
+
* @type {Number}
|
|
75
|
+
*/
|
|
76
|
+
this.itemCount = 0;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Gets or sets the items per page.
|
|
80
|
+
* @type {Number}
|
|
81
|
+
*/
|
|
82
|
+
this.pageSize = 50;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Gets or sets the number of visible pages.
|
|
86
|
+
* @type {Number}
|
|
87
|
+
*/
|
|
88
|
+
this.visiblePages = 5;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Gets or sets the initial page index.
|
|
92
|
+
* @type {Number}
|
|
93
|
+
*/
|
|
94
|
+
this.pageIndex = 1;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Gets or sets the name.
|
|
98
|
+
* @type {String}
|
|
99
|
+
*/
|
|
100
|
+
this.name = '';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Gets or sets a value indicating whether the index change event is fired when the component is rendered.
|
|
104
|
+
* @type {Boolean}
|
|
105
|
+
*/
|
|
106
|
+
this.initialIndexChange = false;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Gets or sets the id of the numeric box from which the settings are cloned.
|
|
110
|
+
* @type {String|null}
|
|
111
|
+
*/
|
|
112
|
+
this.numericBoxId = null;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Gets or sets the id of the hidden input from which the settings are cloned. The hidden input contains the current page index.
|
|
116
|
+
* @type {String|null}
|
|
117
|
+
*/
|
|
118
|
+
this.hiddenInputId = null;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Gets or sets the IDs of the pager buttons.
|
|
122
|
+
* @type {Object}
|
|
123
|
+
*/
|
|
124
|
+
this.buttons = {
|
|
125
|
+
/**
|
|
126
|
+
* Gets or sets the ID of the first page button.
|
|
127
|
+
* @type {String|null}
|
|
128
|
+
*/
|
|
129
|
+
firstPageButtonId: null,
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Gets or sets the ID of the last page button.
|
|
133
|
+
* @type {String|null}
|
|
134
|
+
*/
|
|
135
|
+
lastPageButtonId: null,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Gets or sets the ID of the previous page button.
|
|
139
|
+
* @type {String|null}
|
|
140
|
+
*/
|
|
141
|
+
previousPageButtonId: null,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Gets or sets the ID of the next page button.
|
|
145
|
+
* @type {String|null}
|
|
146
|
+
*/
|
|
147
|
+
nextPageButtonId: null,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Gets or sets the ID of the previous page group button.
|
|
151
|
+
* @type {String|null}
|
|
152
|
+
*/
|
|
153
|
+
previousPageGroupButtonId: null,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Gets or sets the ID of the next page group button.
|
|
157
|
+
* @type {String|null}
|
|
158
|
+
*/
|
|
159
|
+
nextPageGroupButtonId: null,
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Gets or sets the ID of the page button.
|
|
163
|
+
* @type {String|null}
|
|
164
|
+
*/
|
|
165
|
+
pageButtonId: null
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @class
|
|
170
|
+
* @augments componyx.UI.base.Events
|
|
171
|
+
* @memberof componyx.UI.DataPager
|
|
172
|
+
* @property {componyx.UI.base.Event} onFocus - Event which fires when the datapager is focused.
|
|
173
|
+
* @property {componyx.UI.base.Event} onBlur - Event which fires when the datapager is blurred.
|
|
174
|
+
* @property {componyx.UI.base.Event} onIndexChange - Event which fires on a page index change. @see {@link componyx.UI.DataPager.IndexChangeEventArgs}
|
|
175
|
+
* @see {@link componyx.UI.base.Events}
|
|
176
|
+
*/
|
|
177
|
+
function DataPagerEvents(events)
|
|
178
|
+
{
|
|
179
|
+
Object.assign(this, events);
|
|
180
|
+
|
|
181
|
+
this.onFocus = $base.static.createEvent('onFocus');
|
|
182
|
+
this.onBlur = $base.static.createEvent('onBlur');
|
|
183
|
+
this.onIndexChange = $base.static.createEvent('onIndexChange');
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* DataPager events
|
|
187
|
+
* @type {componyx.UI.DataPager.DataPagerEvents}
|
|
188
|
+
*/
|
|
189
|
+
this.events = new DataPagerEvents(this.events);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* DataPager index change event arguments.
|
|
193
|
+
* @typedef {Object} IndexChangeEventArgs
|
|
194
|
+
* @memberof componyx.UI.DataPager
|
|
195
|
+
* @property {Number} pageIndex - The new page index (1-based).
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
// inherit base instance members
|
|
199
|
+
$base.Component.apply(this, [id, properties]);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets buttons template.
|
|
203
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content HTML string or element node as content. Pass null or empty string to remove the existing template.
|
|
204
|
+
*/
|
|
205
|
+
this.setButtonTemplate = function (content)
|
|
206
|
+
{
|
|
207
|
+
_instance.addTemplate('Button', content);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Sets paging info template.
|
|
212
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content HTML string or element node as content. Pass null or empty string to remove the existing template.
|
|
213
|
+
*/
|
|
214
|
+
this.setInfoTemplate = function (content)
|
|
215
|
+
{
|
|
216
|
+
_instance.addTemplate('Info', content);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Gets the index of the current page.
|
|
221
|
+
*/
|
|
222
|
+
this.getPageIndex = function ()
|
|
223
|
+
{
|
|
224
|
+
return _pageIndex;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Sets the page index to the specified number.
|
|
229
|
+
* @param {Number} pageIndex The page index.
|
|
230
|
+
*/
|
|
231
|
+
this.setPageIndex = function (pageIndex)
|
|
232
|
+
{
|
|
233
|
+
setPageIndex(pageIndex);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Gets the page count.
|
|
238
|
+
*/
|
|
239
|
+
this.getPageCount = function ()
|
|
240
|
+
{
|
|
241
|
+
return getPageCount();
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Gets the first item index of the current page.
|
|
246
|
+
*/
|
|
247
|
+
this.getPageFirst = function ()
|
|
248
|
+
{
|
|
249
|
+
return getPageFirst();
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Gets the last item index of the current page.
|
|
254
|
+
*/
|
|
255
|
+
this.getPageLast = function ()
|
|
256
|
+
{
|
|
257
|
+
return getPageLast();
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Renders the component.
|
|
262
|
+
*/
|
|
263
|
+
this.render = function ()
|
|
264
|
+
{
|
|
265
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING)
|
|
266
|
+
{
|
|
267
|
+
// call base render and return
|
|
268
|
+
$base.methods.render.call(_instance, preRender, 'data-pager', false);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// render logic after loading resources
|
|
273
|
+
|
|
274
|
+
if (!_instance.hasTemplate('Button'))
|
|
275
|
+
_instance.addTemplate('Button', '{first}{previous}{pages}{next}{last}{pageJump}');
|
|
276
|
+
|
|
277
|
+
if (!_instance.hasTemplate('Info'))
|
|
278
|
+
_instance.addTemplate('Info', 'Page {pageIndex}-{pageCount} / items {firstItemIndex}-{lastItemIndex} ({itemCount})');
|
|
279
|
+
|
|
280
|
+
draw();
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
function preRender()
|
|
284
|
+
{
|
|
285
|
+
// initialize script and css
|
|
286
|
+
return ['DataPager', ['Button', 'NumericBox']];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function postRender()
|
|
290
|
+
{
|
|
291
|
+
_renderedCount++;
|
|
292
|
+
|
|
293
|
+
if (_renderCount != _renderedCount)
|
|
294
|
+
return;
|
|
295
|
+
|
|
296
|
+
drawInfo();
|
|
297
|
+
|
|
298
|
+
_fireChange = _instance.initialIndexChange;
|
|
299
|
+
|
|
300
|
+
if (!_instance.pageIndex && !$lib.isEmpty(_hidden.value) && !isNaN(_hidden.value))
|
|
301
|
+
_instance.pageIndex = parseInt(_hidden.value, 10);
|
|
302
|
+
|
|
303
|
+
if (_instance.itemCount > 0)
|
|
304
|
+
update(_instance.pageIndex);
|
|
305
|
+
|
|
306
|
+
_fireChange = true;
|
|
307
|
+
|
|
308
|
+
_hidden = _instance.createSyncedInput(_instance.hiddenInputId, function ()
|
|
309
|
+
{
|
|
310
|
+
_instance.setPageIndex(this.value);
|
|
311
|
+
});
|
|
312
|
+
_hidden.__setValue(_pageIndex);
|
|
313
|
+
|
|
314
|
+
$base.methods.postRender.call(_instance);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function draw()
|
|
318
|
+
{
|
|
319
|
+
_renderCount = _renderedCount = 0;
|
|
320
|
+
drawButtons();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function drawButtons()
|
|
324
|
+
{
|
|
325
|
+
var values = {}, id = _instance.id, divPageHolder = null,
|
|
326
|
+
divContainer = document.createElement('div');
|
|
327
|
+
|
|
328
|
+
values['first'] = $lib.format('<div id="{0}_{1}"></div>', id, 'First');
|
|
329
|
+
values['last'] = $lib.format('<div id="{0}_{1}"></div>', id, 'Last');
|
|
330
|
+
values['previous'] = $lib.format('<div id="{0}_{1}"></div>', id, 'Prev');
|
|
331
|
+
values['next'] = $lib.format('<div id="{0}_{1}"></div>', id, 'Next');
|
|
332
|
+
values['pages'] = $lib.format('<div id="{0}_{1}"></div><div id="{0}_{2}"></div><div id="{0}_{3}"></div>', id, 'PrevGroup', 'Pages', 'NextGroup');
|
|
333
|
+
values['pageJump'] = $lib.format('<div id="{0}_{1}"></div>', id, 'PageJump');
|
|
334
|
+
|
|
335
|
+
if (_instance.cssClassButtonHolder)
|
|
336
|
+
divContainer.className = _instance.cssClassButtonHolder;
|
|
337
|
+
|
|
338
|
+
_instance.element.appendChild(divContainer);
|
|
339
|
+
_instance.applyTemplate(divContainer, 'Button', values);
|
|
340
|
+
|
|
341
|
+
divPageHolder = $lib($lib.format('#{0}_{1}', id, 'Pages'));
|
|
342
|
+
|
|
343
|
+
if (divPageHolder && _instance.visiblePages > 0)
|
|
344
|
+
_renderCount = 2 + _instance.visiblePages;
|
|
345
|
+
|
|
346
|
+
if ($lib($lib.format('#{0}_First', id)))
|
|
347
|
+
_renderCount++;
|
|
348
|
+
|
|
349
|
+
if ($lib($lib.format('#{0}_Last', id)))
|
|
350
|
+
_renderCount++;
|
|
351
|
+
|
|
352
|
+
if ($lib($lib.format('#{0}_Prev', id)))
|
|
353
|
+
_renderCount++;
|
|
354
|
+
|
|
355
|
+
if ($lib($lib.format('#{0}_Next', id)))
|
|
356
|
+
_renderCount++;
|
|
357
|
+
|
|
358
|
+
if ($lib($lib.format('#{0}_PageJump', _instance.id)))
|
|
359
|
+
_renderCount++;
|
|
360
|
+
|
|
361
|
+
if ($lib($lib.format('#{0}_First', id)))
|
|
362
|
+
createButton($lib.format('{0}_First', id), _instance.buttons.firstPageButtonId, null, null, _classOption.BUTTONFIRST, _buttonOption.FIRST);
|
|
363
|
+
|
|
364
|
+
if ($lib($lib.format('#{0}_Last', id)))
|
|
365
|
+
createButton($lib.format('{0}_Last', id), _instance.buttons.lastPageButtonId, null, null, _classOption.BUTTONLAST, _buttonOption.LAST);
|
|
366
|
+
|
|
367
|
+
if ($lib($lib.format('#{0}_Prev', id)))
|
|
368
|
+
createButton($lib.format('{0}_Prev', id), _instance.buttons.previousPageButtonId, null, null, _classOption.BUTTONPREVIOUS, _buttonOption.PREVIOUS);
|
|
369
|
+
|
|
370
|
+
if ($lib($lib.format('#{0}_Next', id)))
|
|
371
|
+
createButton($lib.format('{0}_Next', id), _instance.buttons.nextPageButtonId, null, null, _classOption.BUTTONNEXT, _buttonOption.NEXT);
|
|
372
|
+
|
|
373
|
+
if (divPageHolder && _instance.visiblePages > 0)
|
|
374
|
+
{
|
|
375
|
+
divPageHolder.className = _instance.cssClassPageHolder || _classOption.PAGEHOLDER;
|
|
376
|
+
createButton($lib.format('{0}_PrevGroup', id), _instance.buttons.previousPageGroupButtonId, divPageHolder, '...', _classOption.BUTTONPREVIOUSGROUP, _buttonOption.PREVIOUSGROUP);
|
|
377
|
+
|
|
378
|
+
for (var index = 1; index <= _instance.visiblePages; index++)
|
|
379
|
+
{
|
|
380
|
+
createButton($lib.format('{0}_{1}', id, index), _instance.buttons.pageButtonId, divPageHolder, null, _classOption.BUTTONPAGE, index);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
createButton($lib.format('{0}_NextGroup', id), _instance.buttons.nextPageGroupButtonId, divPageHolder, '...', _classOption.BUTTONNEXTGROUP, _buttonOption.NEXTGROUP);
|
|
384
|
+
}
|
|
385
|
+
else
|
|
386
|
+
divPageHolder.style.display = $lib('#' + id + '_PrevGroup').style.display = $lib('#' + id + '_NextGroup').style.display = 'none';
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
if ($lib($lib.format('#{0}_PageJump', _instance.id)))
|
|
390
|
+
createPageJump();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function drawInfo()
|
|
394
|
+
{
|
|
395
|
+
var values = {}, id = _instance.id,
|
|
396
|
+
divContainer = document.createElement('div');
|
|
397
|
+
|
|
398
|
+
values['pageIndex'] = $lib.format('<span id="{0}_{1}"></span>', id, 'PageIndex');
|
|
399
|
+
values['pageCount'] = $lib.format('<span id="{0}_{1}"></span>', id, 'PageCount');
|
|
400
|
+
values['firstItemIndex'] = $lib.format('<span id="{0}_{1}"></span>', id, 'FirstIndex');
|
|
401
|
+
values['lastItemIndex'] = $lib.format('<span id="{0}_{1}"></span>', id, 'LastIndex');
|
|
402
|
+
values['itemCount'] = $lib.format('<span id="{0}_{1}"></span>', id, 'ItemCount');
|
|
403
|
+
|
|
404
|
+
if (_instance.cssClassInfoHolder)
|
|
405
|
+
divContainer.className = _instance.cssClassInfoHolder;
|
|
406
|
+
|
|
407
|
+
_instance.element.appendChild(divContainer);
|
|
408
|
+
_instance.applyTemplate(divContainer, 'Info', values);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function createButton(id, cloneId, container, text, cssClass, option)
|
|
412
|
+
{
|
|
413
|
+
var button = $UI.createComponent(componyx.UI.Button, { id: id, containerElement: container });
|
|
414
|
+
|
|
415
|
+
button.primary = false;
|
|
416
|
+
button.transparent = true;
|
|
417
|
+
button.clone($UI.store[cloneId], _instance);
|
|
418
|
+
|
|
419
|
+
if (!container)
|
|
420
|
+
{
|
|
421
|
+
button.hasIcon = true;
|
|
422
|
+
}
|
|
423
|
+
else
|
|
424
|
+
{
|
|
425
|
+
button.contentAlign = componyx.UI.Button.AlignOption.CENTER;
|
|
426
|
+
button.text = text;
|
|
427
|
+
|
|
428
|
+
if (option != _buttonOption.PREVIOUSGROUP && option != _buttonOption.NEXTGROUP)
|
|
429
|
+
{
|
|
430
|
+
button.type = componyx.UI.Button.TypeOption.RADIOBUTTON;
|
|
431
|
+
button.radioGroupId = container.id;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
button.cssClass = cssClass;
|
|
436
|
+
button.events.onPostRender.priorityAdd(postRender, null);
|
|
437
|
+
button.command = function () { buttonAction(option); };
|
|
438
|
+
button.delegateFocusEvents(_instance);
|
|
439
|
+
button.show();
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function createPageJump()
|
|
443
|
+
{
|
|
444
|
+
var id = $lib.format('{0}_PageJump', _instance.id),
|
|
445
|
+
input = $UI.createComponent(componyx.UI.NumericBox, { id: id });
|
|
446
|
+
|
|
447
|
+
input.clone($UI.store[_instance.numericBoxId], _instance);
|
|
448
|
+
input.minValue = 1;
|
|
449
|
+
input.maxValue = getPageCount();
|
|
450
|
+
input.events.onPostRender.priorityAdd(postRender, null);
|
|
451
|
+
input.events.onChanged.priorityAdd(pageJump, null);
|
|
452
|
+
input.delegateFocusEvents(_instance);
|
|
453
|
+
input.show();
|
|
454
|
+
|
|
455
|
+
return input;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function pageJump(input, args)
|
|
459
|
+
{
|
|
460
|
+
if (!input.getValue())
|
|
461
|
+
{
|
|
462
|
+
input.setValue(_pageIndex);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
update(parseInt(input.getValue(), 10));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function buttonAction(option)
|
|
470
|
+
{
|
|
471
|
+
if (!_instance.itemCount)
|
|
472
|
+
return;
|
|
473
|
+
|
|
474
|
+
var index = 1, pages = _instance.visiblePages;
|
|
475
|
+
|
|
476
|
+
switch (option)
|
|
477
|
+
{
|
|
478
|
+
case _buttonOption.FIRST:
|
|
479
|
+
{
|
|
480
|
+
index = 1;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
case _buttonOption.LAST:
|
|
484
|
+
{
|
|
485
|
+
index = getPageCount();
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
case _buttonOption.PREVIOUS:
|
|
489
|
+
{
|
|
490
|
+
index = _pageIndex - 1;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
case _buttonOption.NEXT:
|
|
494
|
+
{
|
|
495
|
+
index = _pageIndex + 1;
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
case _buttonOption.PREVIOUSGROUP:
|
|
499
|
+
{
|
|
500
|
+
index = (Math.floor((_pageIndex - 1) / pages) * pages);
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
case _buttonOption.NEXTGROUP:
|
|
504
|
+
{
|
|
505
|
+
index = (Math.ceil(_pageIndex / pages) * pages) + 1;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
default:
|
|
509
|
+
{
|
|
510
|
+
index = (Math.floor((_pageIndex - 1) / pages) * pages) + option;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
update(index);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function getPageCount()
|
|
519
|
+
{
|
|
520
|
+
return Math.ceil(_instance.itemCount / _instance.pageSize);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function getFirstItemIndex()
|
|
524
|
+
{
|
|
525
|
+
return ((_pageIndex - 1) * _instance.pageSize) + 1;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function getLastItemIndex()
|
|
529
|
+
{
|
|
530
|
+
var index = ((_pageIndex - 1) * _instance.pageSize) + _instance.pageSize;
|
|
531
|
+
return (index > _instance.itemCount) ? _instance.itemCount : index;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function setPageIndex(index)
|
|
535
|
+
{
|
|
536
|
+
_fireChange = false;
|
|
537
|
+
update(index);
|
|
538
|
+
_fireChange = true;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function update(index)
|
|
542
|
+
{
|
|
543
|
+
var id = _instance.id,
|
|
544
|
+
pages = _instance.visiblePages,
|
|
545
|
+
first = $UI.store[$lib.format('{0}_First', id)],
|
|
546
|
+
last = $UI.store[$lib.format('{0}_Last', id)],
|
|
547
|
+
prev = $UI.store[$lib.format('{0}_Prev', id)],
|
|
548
|
+
next = $UI.store[$lib.format('{0}_Next', id)],
|
|
549
|
+
prevGroup = $UI.store[$lib.format('{0}_PrevGroup', id)],
|
|
550
|
+
nextGroup = $UI.store[$lib.format('{0}_NextGroup', id)],
|
|
551
|
+
input = $UI.store[$lib.format('{0}_PageJump', _instance.id)],
|
|
552
|
+
groupStart = Math.floor((index - 1) / pages) * pages,
|
|
553
|
+
pageCount = getPageCount(),
|
|
554
|
+
button = null;
|
|
555
|
+
|
|
556
|
+
if (index > pageCount)
|
|
557
|
+
index = pageCount;
|
|
558
|
+
|
|
559
|
+
_pageIndex = index;
|
|
560
|
+
|
|
561
|
+
if (_hidden)
|
|
562
|
+
_hidden.__setValue(_pageIndex);
|
|
563
|
+
|
|
564
|
+
if (first && _pageIndex == 1)
|
|
565
|
+
first.disable();
|
|
566
|
+
else if (first)
|
|
567
|
+
first.enable();
|
|
568
|
+
|
|
569
|
+
if (prev && _pageIndex == 1)
|
|
570
|
+
prev.disable();
|
|
571
|
+
else if (prev)
|
|
572
|
+
prev.enable();
|
|
573
|
+
|
|
574
|
+
if (last && _pageIndex == pageCount)
|
|
575
|
+
last.disable();
|
|
576
|
+
else if (last)
|
|
577
|
+
last.enable();
|
|
578
|
+
|
|
579
|
+
if (next && _pageIndex == pageCount)
|
|
580
|
+
next.disable();
|
|
581
|
+
else if (next)
|
|
582
|
+
next.enable();
|
|
583
|
+
|
|
584
|
+
if (prevGroup && !groupStart)
|
|
585
|
+
prevGroup.disable();
|
|
586
|
+
else if (prevGroup)
|
|
587
|
+
prevGroup.enable();
|
|
588
|
+
|
|
589
|
+
if (nextGroup && (groupStart + pages) >= pageCount)
|
|
590
|
+
nextGroup.disable();
|
|
591
|
+
else if (nextGroup)
|
|
592
|
+
nextGroup.enable();
|
|
593
|
+
|
|
594
|
+
if (pageCount <= pages)
|
|
595
|
+
{
|
|
596
|
+
if (prevGroup)
|
|
597
|
+
prevGroup.hide();
|
|
598
|
+
|
|
599
|
+
if (nextGroup)
|
|
600
|
+
nextGroup.hide();
|
|
601
|
+
}
|
|
602
|
+
else
|
|
603
|
+
{
|
|
604
|
+
if (prevGroup)
|
|
605
|
+
prevGroup.show();
|
|
606
|
+
|
|
607
|
+
if (nextGroup)
|
|
608
|
+
nextGroup.show();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if ($lib($lib.format('#{0}_Pages', id)) && pages > 0)
|
|
612
|
+
{
|
|
613
|
+
for (var index = 1; index <= pages; index++)
|
|
614
|
+
{
|
|
615
|
+
button = $UI.store[$lib.format('{0}_{1}', id, index)];
|
|
616
|
+
button.text = (groupStart + index).toString();
|
|
617
|
+
button.updateContent();
|
|
618
|
+
|
|
619
|
+
if ((groupStart + index) > pageCount)
|
|
620
|
+
button.hide();
|
|
621
|
+
else
|
|
622
|
+
{
|
|
623
|
+
button.show();
|
|
624
|
+
|
|
625
|
+
if (button.disabled)
|
|
626
|
+
button.enable();
|
|
627
|
+
|
|
628
|
+
if (groupStart + index == _pageIndex)
|
|
629
|
+
button.select();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
updateLabels();
|
|
635
|
+
|
|
636
|
+
if (input && input.getValue() != _pageIndex.toString())
|
|
637
|
+
{
|
|
638
|
+
input.maxValue = pageCount;
|
|
639
|
+
input.setValue(_pageIndex.toString(), false);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (_fireChange)
|
|
643
|
+
_instance.events.onIndexChange.fire(_instance, { pageIndex: _pageIndex });
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function updateLabels()
|
|
647
|
+
{
|
|
648
|
+
if ($lib($lib.format('#{0}_PageIndex', id)))
|
|
649
|
+
$lib($lib.format('#{0}_PageIndex', id)).innerHTML = _pageIndex;
|
|
650
|
+
|
|
651
|
+
if ($lib($lib.format('#{0}_PageCount', id)))
|
|
652
|
+
$lib($lib.format('#{0}_PageCount', id)).innerHTML = getPageCount();
|
|
653
|
+
|
|
654
|
+
if ($lib($lib.format('#{0}_FirstIndex', id)))
|
|
655
|
+
$lib($lib.format('#{0}_FirstIndex', id)).innerHTML = getFirstItemIndex();
|
|
656
|
+
|
|
657
|
+
if ($lib($lib.format('#{0}_LastIndex', id)))
|
|
658
|
+
$lib($lib.format('#{0}_LastIndex', id)).innerHTML = getLastItemIndex();
|
|
659
|
+
|
|
660
|
+
if ($lib($lib.format('#{0}_ItemCount', id)))
|
|
661
|
+
$lib($lib.format('#{0}_ItemCount', id)).innerHTML = _instance.itemCount;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* @see {@link componyx.UI.base.methods}
|
|
667
|
+
*/
|
|
668
|
+
componyx.UI.DataPager.prototype = Object.create($base.methods);
|
|
669
|
+
componyx.UI.DataPager.prototype.constructor = componyx.UI.DataPager;
|
|
670
|
+
})();
|
|
671
|
+
|
|
672
|
+
const DataPager = componyx.UI.DataPager;
|
|
673
|
+
|
|
674
|
+
export { DataPager };
|