@oat-sa/tao-core-ui 1.58.1 → 1.58.2
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/dist/actionbar.js +386 -395
- package/dist/adder.js +21 -19
- package/dist/animable/absorbable/absorbable.js +204 -213
- package/dist/animable/absorbable/css/absorb.css +1 -0
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +168 -177
- package/dist/autocomplete/css/autocomplete.css +1 -0
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +68 -66
- package/dist/badge/badge.js +188 -197
- package/dist/badge/css/badge.css +1 -0
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs.js +275 -284
- package/dist/btngrouper.js +5 -5
- package/dist/bulkActionPopup.js +490 -495
- package/dist/button.js +283 -291
- package/dist/cascadingComboBox.js +249 -258
- package/dist/ckeditor/ckConfigurator.js +26 -19
- package/dist/ckeditor/dtdHandler.js +11 -9
- package/dist/class/selector.js +441 -450
- package/dist/component/resizable.js +1 -1
- package/dist/component/windowed.js +285 -294
- package/dist/component.js +419 -428
- package/dist/contextualPopup.js +417 -426
- package/dist/dashboard.js +300 -309
- package/dist/datalist.js +753 -762
- package/dist/datatable/filterStrategy/multiple.js +1 -1
- package/dist/datatable/filterStrategy/single.js +1 -1
- package/dist/datatable.js +1527 -1550
- package/dist/dateRange/dateRange.js +393 -402
- package/dist/datetime/picker.js +665 -672
- package/dist/deleter.js +368 -377
- package/dist/destination/selector.js +286 -295
- package/dist/dialog/alert.js +3 -3
- package/dist/dialog/confirm.js +1 -1
- package/dist/dialog/confirmDelete.js +216 -225
- package/dist/dialog.js +650 -654
- package/dist/disabler.js +8 -8
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
- package/dist/documentViewer/providers/pdfViewer.js +184 -193
- package/dist/documentViewer.js +292 -301
- package/dist/dropdown.js +383 -392
- package/dist/durationer.js +5 -5
- package/dist/dynamicComponent.js +597 -598
- package/dist/feedback.js +356 -362
- package/dist/figure/FigureStateActive.js +117 -108
- package/dist/filesender.js +2 -2
- package/dist/filter.js +230 -239
- package/dist/form/dropdownForm.js +355 -357
- package/dist/form/form.js +919 -690
- package/dist/form/simpleForm.js +1 -1
- package/dist/form/validator/renderer.js +233 -235
- package/dist/form/validator/validator.js +257 -189
- package/dist/form/widget/definitions.js +1 -1
- package/dist/form/widget/providers/checkBox.js +254 -259
- package/dist/form/widget/providers/comboBox.js +187 -192
- package/dist/form/widget/providers/default.js +8 -9
- package/dist/form/widget/providers/hidden.js +170 -179
- package/dist/form/widget/providers/hiddenBox.js +262 -267
- package/dist/form/widget/providers/radioBox.js +216 -225
- package/dist/form/widget/providers/textArea.js +187 -196
- package/dist/form/widget/providers/textBox.js +2 -3
- package/dist/form/widget/widget.js +473 -475
- package/dist/formValidator/formValidator.js +1 -1
- package/dist/formValidator/highlighters/message.js +1 -1
- package/dist/generis/form/form.js +314 -323
- package/dist/generis/validator/validator.js +209 -218
- package/dist/generis/widget/checkBox/checkBox.js +218 -227
- package/dist/generis/widget/comboBox/comboBox.js +179 -188
- package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
- package/dist/generis/widget/textBox/textBox.js +169 -178
- package/dist/generis/widget/widget.js +246 -255
- package/dist/groupedComboBox.js +222 -231
- package/dist/groupvalidator.js +2 -2
- package/dist/highlighter.js +967 -958
- package/dist/image/ImgStateActive/helper.js +7 -5
- package/dist/image/ImgStateActive/initHelper.js +49 -43
- package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
- package/dist/image/ImgStateActive/mediaSizer.js +14 -12
- package/dist/image/ImgStateActive.js +72 -70
- package/dist/incrementer.js +6 -6
- package/dist/inplacer.js +6 -6
- package/dist/itemButtonList/css/item-button-list.css +1 -0
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +439 -435
- package/dist/keyNavigation/navigableDomElement.js +51 -38
- package/dist/keyNavigation/navigator.js +85 -70
- package/dist/listbox.js +460 -469
- package/dist/liststyler.js +8 -8
- package/dist/loadingButton/loadingButton.js +209 -218
- package/dist/lock.js +476 -485
- package/dist/login/login.js +475 -484
- package/dist/maths/calculator/basicCalculator.js +235 -244
- package/dist/maths/calculator/calculatorComponent.js +3 -3
- package/dist/maths/calculator/core/board.js +772 -781
- package/dist/maths/calculator/core/expression.js +476 -485
- package/dist/maths/calculator/core/labels.js +228 -237
- package/dist/maths/calculator/core/tokenizer.js +1 -1
- package/dist/maths/calculator/core/tokens.js +163 -170
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
- package/dist/maths/calculator/scientificCalculator.js +327 -336
- package/dist/mediaEditor/mediaEditorComponent.js +238 -245
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
- package/dist/mediaplayer/players/html5.js +666 -675
- package/dist/mediaplayer/players/youtube.js +419 -424
- package/dist/mediaplayer/support.js +11 -10
- package/dist/mediaplayer/utils/reminder.js +14 -13
- package/dist/mediaplayer/utils/timeObserver.js +10 -11
- package/dist/mediaplayer/youtubeManager.js +164 -145
- package/dist/mediaplayer.js +1565 -1520
- package/dist/mediasizer.js +669 -678
- package/dist/modal.js +10 -17
- package/dist/pageSizeSelector.js +219 -228
- package/dist/pagination/providers/pages.js +280 -289
- package/dist/pagination/providers/simple.js +192 -201
- package/dist/previewer.js +30 -30
- package/dist/progressbar.js +4 -4
- package/dist/report.js +347 -356
- package/dist/resource/filters.js +271 -280
- package/dist/resource/list.js +1264 -1273
- package/dist/resource/selector.js +865 -874
- package/dist/resource/tree.js +1483 -1492
- package/dist/resourcemgr/fileBrowser.js +564 -569
- package/dist/resourcemgr/filePreview.js +16 -16
- package/dist/resourcemgr/fileSelector.js +515 -524
- package/dist/resourcemgr/util/updatePermissions.js +2 -2
- package/dist/resourcemgr.js +306 -315
- package/dist/searchModal/advancedSearch.js +796 -767
- package/dist/searchModal.js +114 -91
- package/dist/switch/switch.js +298 -307
- package/dist/tabs.js +598 -575
- package/dist/taskQueue/status.js +312 -321
- package/dist/taskQueue/table.js +375 -384
- package/dist/taskQueue/taskQueueModel.js +488 -472
- package/dist/taskQueueButton/taskable.js +264 -273
- package/dist/taskQueueButton/treeButton.js +189 -198
- package/dist/themeLoader.js +24 -23
- package/dist/themes.js +1 -1
- package/dist/toggler.js +3 -3
- package/dist/tooltip.js +295 -304
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup.js +311 -320
- package/dist/uploader.js +687 -696
- package/dist/validator/Report.js +1 -1
- package/dist/validator/Validator.js +3 -3
- package/dist/validator/validators.js +9 -9
- package/dist/validator.js +240 -230
- package/dist/waitForMedia.js +1 -1
- package/package.json +3 -3
- package/src/animable/absorbable/css/absorb.css +1 -0
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css +1 -0
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/badge/css/badge.css +1 -0
- package/src/badge/css/badge.css.map +1 -1
- package/src/ckeditor/ckConfigurator.js +4 -0
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/.DS_Store +0 -0
- package/src/css/basic.css +0 -7826
- package/src/css/basic.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
- package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
- package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
- package/src/scss/.DS_Store +0 -0
- package/src/scss/basic.scss +0 -16
- package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
- package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
- package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
- package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
- package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
- package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
- package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
- package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
- package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
- package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
- package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
- package/src/scss/font/tao/tao.eot +0 -0
- package/src/scss/font/tao/tao.svg +0 -235
- package/src/scss/font/tao/tao.ttf +0 -0
- package/src/scss/font/tao/tao.woff +0 -0
- package/src/scss/inc/_base.scss +0 -496
- package/src/scss/inc/_bootstrap.scss +0 -6
- package/src/scss/inc/_buttons.scss +0 -114
- package/src/scss/inc/_colors.scss +0 -88
- package/src/scss/inc/_feedback.scss +0 -150
- package/src/scss/inc/_flex-grid.scss +0 -15
- package/src/scss/inc/_fonts.scss +0 -4
- package/src/scss/inc/_forms.scss +0 -827
- package/src/scss/inc/_functions.scss +0 -283
- package/src/scss/inc/_grid.scss +0 -66
- package/src/scss/inc/_jquery.nouislider.scss +0 -254
- package/src/scss/inc/_normalize.scss +0 -528
- package/src/scss/inc/_report.scss +0 -68
- package/src/scss/inc/_secondary-properties.scss +0 -89
- package/src/scss/inc/_select2.scss +0 -634
- package/src/scss/inc/_toolbars.scss +0 -155
- package/src/scss/inc/_tooltip.scss +0 -312
- package/src/scss/inc/_variables.scss +0 -21
- package/src/scss/inc/base/_highlight.scss +0 -5
- package/src/scss/inc/base/_list-style.scss +0 -59
- package/src/scss/inc/base/_svg.scss +0 -3
- package/src/scss/inc/base/_table.scss +0 -63
- package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
- package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
- package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
- package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
package/dist/datetime/picker.js
CHANGED
|
@@ -1,779 +1,772 @@
|
|
|
1
1
|
define(['lodash', 'i18n', 'moment', 'ui/component', 'lib/flatpickr/flatpickr', 'lib/flatpickr/l10n/index', 'handlebars', 'lib/dompurify/purify', 'css!lib/flatpickr/flatpickr.css', 'css!ui/datetime/css/picker.css'], function (_, __, moment, component, flatpickr, flatpickrLocalization, Handlebars, DOMPurify, flatpickr_css, picker_css) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
4
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
5
|
+
moment = moment && Object.prototype.hasOwnProperty.call(moment, 'default') ? moment['default'] : moment;
|
|
6
|
+
component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
|
|
7
|
+
flatpickr = flatpickr && Object.prototype.hasOwnProperty.call(flatpickr, 'default') ? flatpickr['default'] : flatpickr;
|
|
8
|
+
flatpickrLocalization = flatpickrLocalization && Object.prototype.hasOwnProperty.call(flatpickrLocalization, 'default') ? flatpickrLocalization['default'] : flatpickrLocalization;
|
|
9
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
10
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
11
|
+
|
|
12
|
+
function _typeof(obj) {
|
|
13
|
+
"@babel/helpers - typeof";
|
|
14
|
+
|
|
15
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
16
|
+
return typeof obj;
|
|
17
|
+
} : function (obj) {
|
|
18
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
19
|
+
}, _typeof(obj);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function Helpers0 (hb) {
|
|
23
|
+
//register a i18n helper
|
|
24
|
+
hb.registerHelper('__', function (key) {
|
|
25
|
+
return __(key);
|
|
26
|
+
});
|
|
12
27
|
/**
|
|
13
|
-
*
|
|
14
|
-
* modify it under the terms of the GNU General Public License
|
|
15
|
-
* as published by the Free Software Foundation; under version 2
|
|
16
|
-
* of the License (non-upgradable).
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License
|
|
24
|
-
* along with this program; if not, write to the Free Software
|
|
25
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
26
|
-
*
|
|
27
|
-
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
28
|
-
*
|
|
28
|
+
* Register dompurify helper
|
|
29
29
|
*
|
|
30
|
+
* https://github.com/cure53/DOMPurify
|
|
31
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
32
|
+
* to make output safe for template systems
|
|
30
33
|
*/
|
|
31
|
-
function Helpers0 (hb) {
|
|
32
|
-
//register a i18n helper
|
|
33
|
-
hb.registerHelper('__', function (key) {
|
|
34
|
-
return __(key);
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Register dompurify helper
|
|
38
|
-
*
|
|
39
|
-
* https://github.com/cure53/DOMPurify
|
|
40
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
41
|
-
* to make output safe for template systems
|
|
42
|
-
*/
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
57
|
-
var fragments = [];
|
|
58
|
-
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
59
|
-
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
60
|
-
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
35
|
+
hb.registerHelper('dompurify', function (context) {
|
|
36
|
+
return DOMPurify.sanitize(context);
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Register join helper
|
|
40
|
+
*
|
|
41
|
+
* Example :
|
|
42
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
43
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
44
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
45
|
+
*/
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
48
|
+
var fragments = [];
|
|
49
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
50
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
51
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
value = value ? 'true' : 'false';
|
|
68
|
-
} else if (typeof value === 'object') {
|
|
69
|
-
value = _.values(value).join(' ');
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
value = '';
|
|
73
|
-
}
|
|
53
|
+
_.forIn(arr, function (value, key) {
|
|
54
|
+
var fragment = '';
|
|
74
55
|
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
if (value !== null || value !== undefined) {
|
|
57
|
+
if (typeof value === 'boolean') {
|
|
58
|
+
value = value ? 'true' : 'false';
|
|
59
|
+
} else if (_typeof(value) === 'object') {
|
|
60
|
+
value = _.values(value).join(' ');
|
|
77
61
|
}
|
|
62
|
+
} else {
|
|
63
|
+
value = '';
|
|
64
|
+
}
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return fragments.join(fragmentGlue);
|
|
84
|
-
}); //register a classic "for loop" helper
|
|
85
|
-
//it also adds a local variable "i" as the index in each iteration loop
|
|
86
|
-
|
|
87
|
-
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
88
|
-
var ret = '';
|
|
89
|
-
startIndex = parseInt(startIndex);
|
|
90
|
-
stopIndex = parseInt(stopIndex);
|
|
91
|
-
increment = parseInt(increment);
|
|
92
|
-
|
|
93
|
-
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
94
|
-
ret += options.fn(_.extend({}, this, {
|
|
95
|
-
i: i
|
|
96
|
-
}));
|
|
66
|
+
if (keyValueGlue !== undefined) {
|
|
67
|
+
fragment += key + keyValueGlue;
|
|
97
68
|
}
|
|
98
69
|
|
|
99
|
-
|
|
70
|
+
fragment += wrapper + value + wrapper;
|
|
71
|
+
fragments.push(fragment);
|
|
100
72
|
});
|
|
101
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
102
|
-
if (var1 == var2) {
|
|
103
|
-
return options.fn(this);
|
|
104
|
-
} else {
|
|
105
|
-
return options.inverse(this);
|
|
106
|
-
}
|
|
107
|
-
}); // register a "get property" helper
|
|
108
|
-
// it gets the named property from the provided context
|
|
109
73
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// it checks if value is in array
|
|
74
|
+
return fragments.join(fragmentGlue);
|
|
75
|
+
}); //register a classic "for loop" helper
|
|
76
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
114
77
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
78
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
79
|
+
var ret = '';
|
|
80
|
+
startIndex = parseInt(startIndex);
|
|
81
|
+
stopIndex = parseInt(stopIndex);
|
|
82
|
+
increment = parseInt(increment);
|
|
121
83
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
127
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
128
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
129
|
-
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing, self=this;
|
|
130
|
-
|
|
131
|
-
function program1(depth0,data) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return "control-buttons";
|
|
84
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
85
|
+
ret += options.fn(_.extend({}, this, {
|
|
86
|
+
i: i
|
|
87
|
+
}));
|
|
135
88
|
}
|
|
136
89
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
90
|
+
return ret;
|
|
91
|
+
});
|
|
92
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
93
|
+
if (var1 == var2) {
|
|
94
|
+
return options.fn(this);
|
|
95
|
+
} else {
|
|
96
|
+
return options.inverse(this);
|
|
144
97
|
}
|
|
98
|
+
}); // register a "get property" helper
|
|
99
|
+
// it gets the named property from the provided context
|
|
145
100
|
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
151
|
-
+ "\"";
|
|
152
|
-
return buffer;
|
|
153
|
-
}
|
|
101
|
+
hb.registerHelper('property', function (name, context) {
|
|
102
|
+
return context[name] || '';
|
|
103
|
+
}); // register an 'includes' helper
|
|
104
|
+
// it checks if value is in array
|
|
154
105
|
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
buffer += "value=\""
|
|
159
|
-
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.value)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
160
|
-
+ "\"";
|
|
161
|
-
return buffer;
|
|
106
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
107
|
+
if (_.contains(haystack, needle)) {
|
|
108
|
+
return options.fn(this);
|
|
162
109
|
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!Helpers0.__initialized) {
|
|
114
|
+
Helpers0(Handlebars);
|
|
115
|
+
Helpers0.__initialized = true;
|
|
116
|
+
}
|
|
117
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
118
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
119
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
120
|
+
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing, self=this;
|
|
121
|
+
|
|
122
|
+
function program1(depth0,data) {
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
return "control-buttons";
|
|
126
|
+
}
|
|
163
127
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
128
|
+
function program3(depth0,data) {
|
|
129
|
+
|
|
130
|
+
var buffer = "", stack1;
|
|
131
|
+
buffer += "id=\""
|
|
132
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
133
|
+
+ "\"";
|
|
134
|
+
return buffer;
|
|
135
|
+
}
|
|
172
136
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
137
|
+
function program5(depth0,data) {
|
|
138
|
+
|
|
139
|
+
var buffer = "", stack1;
|
|
140
|
+
buffer += "name=\""
|
|
141
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
142
|
+
+ "\"";
|
|
143
|
+
return buffer;
|
|
144
|
+
}
|
|
181
145
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
146
|
+
function program7(depth0,data) {
|
|
147
|
+
|
|
148
|
+
var buffer = "", stack1;
|
|
149
|
+
buffer += "value=\""
|
|
150
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.value)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
151
|
+
+ "\"";
|
|
152
|
+
return buffer;
|
|
153
|
+
}
|
|
190
154
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Clear the date time picker", options) : helperMissing.call(depth0, "__", "Clear the date time picker", options)))
|
|
200
|
-
+ "\" aria-label=\""
|
|
201
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Clear the date time picker", options) : helperMissing.call(depth0, "__", "Clear the date time picker", options)))
|
|
202
|
-
+ "\">\n <span class=\"icon-reset\" role=\"img\"></span>\n </button>\n ";
|
|
203
|
-
return buffer;
|
|
204
|
-
}
|
|
155
|
+
function program9(depth0,data) {
|
|
156
|
+
|
|
157
|
+
var buffer = "", stack1;
|
|
158
|
+
buffer += "placeholder=\""
|
|
159
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.placeholder)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
160
|
+
+ "\"";
|
|
161
|
+
return buffer;
|
|
162
|
+
}
|
|
205
163
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
buffer += "\">\n <input type=\"text\" disabled\n ";
|
|
214
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.id), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
|
215
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
216
|
-
buffer += "\n ";
|
|
217
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.name), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
|
218
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
219
|
-
buffer += "\n ";
|
|
220
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.value), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
|
221
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
222
|
-
buffer += "\n ";
|
|
223
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.placeholder), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
|
|
224
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
225
|
-
buffer += "\n ";
|
|
226
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.pattern), {hash:{},inverse:self.noop,fn:self.program(11, program11, data),data:data});
|
|
227
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
228
|
-
buffer += "\n ";
|
|
229
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.label), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
|
|
230
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
231
|
-
buffer += "\n />\n ";
|
|
232
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.controlButtons), {hash:{},inverse:self.noop,fn:self.program(15, program15, data),data:data});
|
|
233
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
234
|
-
buffer += "\n</div>\n";
|
|
235
|
-
return buffer;
|
|
236
|
-
});
|
|
237
|
-
function dateTimePickerTpl(data, options, asString) {
|
|
238
|
-
var html = Template(data, options);
|
|
239
|
-
return (asString || true) ? html : $(html);
|
|
164
|
+
function program11(depth0,data) {
|
|
165
|
+
|
|
166
|
+
var buffer = "", stack1;
|
|
167
|
+
buffer += "pattern=\""
|
|
168
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.pattern)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
169
|
+
+ "\"";
|
|
170
|
+
return buffer;
|
|
240
171
|
}
|
|
241
172
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
251
|
-
* GNU General Public License for more details.
|
|
252
|
-
*
|
|
253
|
-
* You should have received a copy of the GNU General Public License
|
|
254
|
-
* along with this program; if not, write to the Free Software
|
|
255
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
256
|
-
*
|
|
257
|
-
* Copyright (c) 2019 (original work) Open Assessment Technologies SA
|
|
258
|
-
*
|
|
259
|
-
*/
|
|
260
|
-
/**
|
|
261
|
-
* The supported formats
|
|
262
|
-
*/
|
|
173
|
+
function program13(depth0,data) {
|
|
174
|
+
|
|
175
|
+
var buffer = "", stack1;
|
|
176
|
+
buffer += "aria-label=\""
|
|
177
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
178
|
+
+ "\"";
|
|
179
|
+
return buffer;
|
|
180
|
+
}
|
|
263
181
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Possible setups for the picker
|
|
280
|
-
*/
|
|
182
|
+
function program15(depth0,data) {
|
|
183
|
+
|
|
184
|
+
var buffer = "", helper, options;
|
|
185
|
+
buffer += "\n <button type=\"button\" disabled class=\"picker-toggle\" title=\""
|
|
186
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle the date time picker", options) : helperMissing.call(depth0, "__", "Toggle the date time picker", options)))
|
|
187
|
+
+ "\" aria-label=\""
|
|
188
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle the date time picker", options) : helperMissing.call(depth0, "__", "Toggle the date time picker", options)))
|
|
189
|
+
+ "\" >\n <span class=\"icon-calendar\" role=\"img\"></span>\n </button>\n <button type=\"button\" disabled class=\"picker-clear\" title=\""
|
|
190
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Clear the date time picker", options) : helperMissing.call(depth0, "__", "Clear the date time picker", options)))
|
|
191
|
+
+ "\" aria-label=\""
|
|
192
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Clear the date time picker", options) : helperMissing.call(depth0, "__", "Clear the date time picker", options)))
|
|
193
|
+
+ "\">\n <span class=\"icon-reset\" role=\"img\"></span>\n </button>\n ";
|
|
194
|
+
return buffer;
|
|
195
|
+
}
|
|
281
196
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
197
|
+
buffer += "<div class=\"datetime-picker ";
|
|
198
|
+
if (helper = helpers.setup) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
199
|
+
else { helper = (depth0 && depth0.setup); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
200
|
+
buffer += escapeExpression(stack1)
|
|
201
|
+
+ " ";
|
|
202
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.controlButtons), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
|
203
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
204
|
+
buffer += "\">\n <input type=\"text\" disabled\n ";
|
|
205
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.id), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
|
206
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
207
|
+
buffer += "\n ";
|
|
208
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.name), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
|
209
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
210
|
+
buffer += "\n ";
|
|
211
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.value), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
|
212
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
213
|
+
buffer += "\n ";
|
|
214
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.placeholder), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
|
|
215
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
216
|
+
buffer += "\n ";
|
|
217
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.pattern), {hash:{},inverse:self.noop,fn:self.program(11, program11, data),data:data});
|
|
218
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
219
|
+
buffer += "\n ";
|
|
220
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.label), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
|
|
221
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
222
|
+
buffer += "\n />\n ";
|
|
223
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.controlButtons), {hash:{},inverse:self.noop,fn:self.program(15, program15, data),data:data});
|
|
224
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
225
|
+
buffer += "\n</div>\n";
|
|
226
|
+
return buffer;
|
|
227
|
+
});
|
|
228
|
+
function dateTimePickerTpl(data, options, asString) {
|
|
229
|
+
var html = Template(data, options);
|
|
230
|
+
return (asString || true) ? html : $(html);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* This program is free software; you can redistribute it and/or
|
|
235
|
+
* modify it under the terms of the GNU General Public License
|
|
236
|
+
* as published by the Free Software Foundation; under version 2
|
|
237
|
+
* of the License (non-upgradable).
|
|
238
|
+
*
|
|
239
|
+
* This program is distributed in the hope that it will be useful,
|
|
240
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
241
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
242
|
+
* GNU General Public License for more details.
|
|
243
|
+
*
|
|
244
|
+
* You should have received a copy of the GNU General Public License
|
|
245
|
+
* along with this program; if not, write to the Free Software
|
|
246
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
247
|
+
*
|
|
248
|
+
* Copyright (c) 2019 (original work) Open Assessment Technologies SA
|
|
249
|
+
*
|
|
250
|
+
*/
|
|
251
|
+
/**
|
|
252
|
+
* The supported formats
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
var formats = {
|
|
256
|
+
date: {
|
|
257
|
+
default: 'YYYY-MM-DD',
|
|
258
|
+
localized: 'L'
|
|
259
|
+
},
|
|
260
|
+
time: {
|
|
261
|
+
default: 'HH:mm',
|
|
262
|
+
localized: 'LT'
|
|
263
|
+
},
|
|
264
|
+
datetime: {
|
|
265
|
+
default: 'YYYY-MM-DD HH:mm',
|
|
266
|
+
localized: 'L LT'
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Possible setups for the picker
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
var setups = {
|
|
274
|
+
'date-range': {
|
|
275
|
+
mode: 'range',
|
|
276
|
+
label: __('date range'),
|
|
277
|
+
format: formats.date
|
|
278
|
+
},
|
|
279
|
+
'datetime-range': {
|
|
280
|
+
mode: 'range',
|
|
281
|
+
label: __('date time range'),
|
|
282
|
+
enableTime: true,
|
|
283
|
+
format: formats.datetime
|
|
284
|
+
},
|
|
285
|
+
date: {
|
|
286
|
+
mode: 'single',
|
|
287
|
+
format: formats.date
|
|
288
|
+
},
|
|
289
|
+
time: {
|
|
290
|
+
mode: 'single',
|
|
291
|
+
enableTime: true,
|
|
292
|
+
label: __('time'),
|
|
293
|
+
noCalendar: true,
|
|
294
|
+
format: formats.time
|
|
295
|
+
},
|
|
296
|
+
datetime: {
|
|
297
|
+
mode: 'single',
|
|
298
|
+
enableTime: true,
|
|
299
|
+
label: __('date time'),
|
|
300
|
+
format: formats.datetime
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* List of supported constraints
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
var supportedConstraints = ['minDate', 'maxDate', 'enable', 'disable'];
|
|
308
|
+
/**
|
|
309
|
+
* Checks translation existing for given locale
|
|
310
|
+
* @param {String} locale
|
|
311
|
+
* @returns {Boolean}
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
var hasTranslationsForLocale = function hasTranslationsForLocale(locale) {
|
|
315
|
+
return _.isObject(flatpickrLocalization[locale]);
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Detects document language
|
|
319
|
+
* @returns {String | undefined}
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
var getDefaultLocale = function getDefaultLocale() {
|
|
324
|
+
var documentLang = window.document.documentElement.getAttribute('lang');
|
|
325
|
+
var documentLocale = documentLang && documentLang.split('-')[0];
|
|
326
|
+
|
|
327
|
+
if (documentLocale && hasTranslationsForLocale(documentLocale)) {
|
|
328
|
+
return documentLocale;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* The default configuration
|
|
333
|
+
* @see dateTimePickerFactory
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
var defaultConfig = {
|
|
338
|
+
setup: 'date',
|
|
339
|
+
controlButtons: false,
|
|
340
|
+
locale: getDefaultLocale(),
|
|
341
|
+
useLocalizedFormat: false,
|
|
342
|
+
constraints: {}
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Get the long date/time format from the localized format (LT to 'DD/MM/YYYY HH:mm')
|
|
346
|
+
* @param {String} locale - 2 digits locale code (en, fr, de, etc.)
|
|
347
|
+
* @param {String} localizedFormat - see moment's localized format (L, LT, LLLL, ...)
|
|
348
|
+
* @returns {String|boolean} the long date/time format
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
var getLongLocalizedFormat = function getLongLocalizedFormat(locale, localizedFormat) {
|
|
352
|
+
if (/[LT]+/.test(localizedFormat) && locale) {
|
|
353
|
+
return localizedFormat.split(' ').map(function (format) {
|
|
354
|
+
return moment(new Date()).locale(locale).localeData().longDateFormat(format);
|
|
355
|
+
}).join(' ');
|
|
356
|
+
}
|
|
315
357
|
|
|
316
|
-
|
|
358
|
+
return false;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Does the given date/time format uses the am/pm pattern ?
|
|
362
|
+
* @param {String} format - moment format
|
|
363
|
+
* @returns {Boolean} true if the contains am/pm
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
var isFormatAmPm = function isFormatAmPm(format) {
|
|
368
|
+
return format && /a$/i.test(format);
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Does the given date/time format contains seconds ?
|
|
372
|
+
* @param {String} format - moment format
|
|
373
|
+
* @returns {Boolean} true if the format contains seconds
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
var isFormatInSeconds = function isFormatInSeconds(format) {
|
|
378
|
+
return format && /(:ss)+/i.test(format);
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* The component factory
|
|
382
|
+
*
|
|
383
|
+
* @param {HTMLElement|jQuery} container - where to append the component
|
|
384
|
+
* @param {Object} [config]
|
|
385
|
+
* @param {String} [config.setup = date] - the picker setup in date-range, datetime-range, date, time and datetime
|
|
386
|
+
* @param {String} [config.locale] - the picker local
|
|
387
|
+
* @param {String} [config.useLocalzedFormat = false] - does the locale is used to define the format
|
|
388
|
+
* @param {String} [config.format] - define your own date/time format for the instance
|
|
389
|
+
* @param {Boolean} [config.controlButtons = false] - does the field have controls to trigger opening and reset
|
|
390
|
+
* @param {Object} [config.constraints] - date time selection constraints
|
|
391
|
+
* @param {Object} [config.constraints] - date time selection constraints
|
|
392
|
+
* @param {Array<String|Date>} [config.constraints.disable] - list of dates to disable
|
|
393
|
+
* @param {Array<String|Date>} [config.constraints.enable] - list of dates to enable (if some are disabled)
|
|
394
|
+
* @param {String|Date} [config.constraints.minDate] - minimum date to start picking from
|
|
395
|
+
* @param {String|Date} [config.constraints.maxDate] - maximum date to start picking from
|
|
396
|
+
*
|
|
397
|
+
* @param {HTMLInputElement} [config.replaceField] - an input field to replace. The field attr are taken instead of config.field
|
|
398
|
+
* @param {Object} [config.field] - the input field configuration
|
|
399
|
+
* @param {String} [config.field.name] - the input field name
|
|
400
|
+
* @param {String} [config.field.id] - the input field id
|
|
401
|
+
* @param {String} [config.field.placeholder] - the input field placeholder
|
|
402
|
+
* @param {String} [config.field.pattern] - the input field pattern mask
|
|
403
|
+
* @param {String} [config.field.value] - the input field value
|
|
404
|
+
* @param {String} [config.field.label] - label the field for a11y
|
|
405
|
+
*
|
|
406
|
+
* @returns {dateTimePickerComponent} the component instance
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
function dateTimePickerFactory(container, options) {
|
|
411
|
+
var format = '';
|
|
412
|
+
var value = '';
|
|
317
413
|
/**
|
|
318
|
-
*
|
|
319
|
-
* @param {String} locale
|
|
320
|
-
* @returns {Boolean}
|
|
414
|
+
* @typedef {Object} dateTimePicker
|
|
321
415
|
*/
|
|
322
416
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
417
|
+
var dateTimePicker = component({
|
|
418
|
+
/**
|
|
419
|
+
* Get the current value
|
|
420
|
+
* @returns {String} the field value, null if none
|
|
421
|
+
*/
|
|
422
|
+
getValue: function getValue() {
|
|
423
|
+
if (this.is('rendered')) {
|
|
424
|
+
return this.controls.input.value;
|
|
425
|
+
}
|
|
328
426
|
|
|
427
|
+
return null;
|
|
428
|
+
},
|
|
329
429
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Set the current value
|
|
432
|
+
* @param {String|Date} newValue - the new value matching the format
|
|
433
|
+
*/
|
|
434
|
+
setValue: function setValue(newValue) {
|
|
435
|
+
if (this.is('ready')) {
|
|
436
|
+
value = newValue;
|
|
333
437
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* The default configuration
|
|
340
|
-
* @see dateTimePickerFactory
|
|
341
|
-
*/
|
|
438
|
+
if (_.isString(value)) {
|
|
439
|
+
this.controls.input.value = value;
|
|
440
|
+
}
|
|
342
441
|
|
|
442
|
+
this.picker.setDate(value, true);
|
|
443
|
+
}
|
|
343
444
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
controlButtons: false,
|
|
347
|
-
locale: getDefaultLocale(),
|
|
348
|
-
useLocalizedFormat: false,
|
|
349
|
-
constraints: {}
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* Get the long date/time format from the localized format (LT to 'DD/MM/YYYY HH:mm')
|
|
353
|
-
* @param {String} locale - 2 digits locale code (en, fr, de, etc.)
|
|
354
|
-
* @param {String} localizedFormat - see moment's localized format (L, LT, LLLL, ...)
|
|
355
|
-
* @returns {String|boolean} the long date/time format
|
|
356
|
-
*/
|
|
445
|
+
return null;
|
|
446
|
+
},
|
|
357
447
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
448
|
+
/**
|
|
449
|
+
* Get the dates currently selected.
|
|
450
|
+
* Usefull for the range mode to get the date list
|
|
451
|
+
* @returns {Array<[Date|String]>|boolean} the selected dates
|
|
452
|
+
*/
|
|
453
|
+
getSelectedDates: function getSelectedDates() {
|
|
454
|
+
var selection;
|
|
364
455
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Does the given date/time format uses the am/pm pattern ?
|
|
369
|
-
* @param {String} format - moment format
|
|
370
|
-
* @returns {Boolean} true if the contains am/pm
|
|
371
|
-
*/
|
|
456
|
+
if (this.is('ready') && this.picker) {
|
|
457
|
+
selection = this.picker.selectedDates;
|
|
372
458
|
|
|
459
|
+
if (selection && !_.isArray(selection)) {
|
|
460
|
+
return [selection];
|
|
461
|
+
}
|
|
373
462
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
};
|
|
377
|
-
/**
|
|
378
|
-
* Does the given date/time format contains seconds ?
|
|
379
|
-
* @param {String} format - moment format
|
|
380
|
-
* @returns {Boolean} true if the format contains seconds
|
|
381
|
-
*/
|
|
463
|
+
return selection;
|
|
464
|
+
}
|
|
382
465
|
|
|
466
|
+
return false;
|
|
467
|
+
},
|
|
383
468
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
* @param {Object} [config]
|
|
392
|
-
* @param {String} [config.setup = date] - the picker setup in date-range, datetime-range, date, time and datetime
|
|
393
|
-
* @param {String} [config.locale] - the picker local
|
|
394
|
-
* @param {String} [config.useLocalzedFormat = false] - does the locale is used to define the format
|
|
395
|
-
* @param {String} [config.format] - define your own date/time format for the instance
|
|
396
|
-
* @param {Boolean} [config.controlButtons = false] - does the field have controls to trigger opening and reset
|
|
397
|
-
* @param {Object} [config.constraints] - date time selection constraints
|
|
398
|
-
* @param {Object} [config.constraints] - date time selection constraints
|
|
399
|
-
* @param {Array<String|Date>} [config.constraints.disable] - list of dates to disable
|
|
400
|
-
* @param {Array<String|Date>} [config.constraints.enable] - list of dates to enable (if some are disabled)
|
|
401
|
-
* @param {String|Date} [config.constraints.minDate] - minimum date to start picking from
|
|
402
|
-
* @param {String|Date} [config.constraints.maxDate] - maximum date to start picking from
|
|
403
|
-
*
|
|
404
|
-
* @param {HTMLInputElement} [config.replaceField] - an input field to replace. The field attr are taken instead of config.field
|
|
405
|
-
* @param {Object} [config.field] - the input field configuration
|
|
406
|
-
* @param {String} [config.field.name] - the input field name
|
|
407
|
-
* @param {String} [config.field.id] - the input field id
|
|
408
|
-
* @param {String} [config.field.placeholder] - the input field placeholder
|
|
409
|
-
* @param {String} [config.field.pattern] - the input field pattern mask
|
|
410
|
-
* @param {String} [config.field.value] - the input field value
|
|
411
|
-
* @param {String} [config.field.label] - label the field for a11y
|
|
412
|
-
*
|
|
413
|
-
* @returns {dateTimePickerComponent} the component instance
|
|
414
|
-
*/
|
|
469
|
+
/**
|
|
470
|
+
* Get the date/time format description, ie. 'YYYY-MM-DD'
|
|
471
|
+
* @returns {String} the format
|
|
472
|
+
*/
|
|
473
|
+
getFormat: function getFormat() {
|
|
474
|
+
return format;
|
|
475
|
+
},
|
|
415
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Open the picker
|
|
479
|
+
* @returns {dateTimePicker} chains
|
|
480
|
+
* @fires dateTimePicker#open
|
|
481
|
+
*/
|
|
482
|
+
open: function open() {
|
|
483
|
+
if (this.is('ready')) {
|
|
484
|
+
this.picker.open();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return this;
|
|
488
|
+
},
|
|
416
489
|
|
|
417
|
-
function dateTimePickerFactory(container, options) {
|
|
418
|
-
var format = '';
|
|
419
|
-
var value = '';
|
|
420
490
|
/**
|
|
421
|
-
*
|
|
491
|
+
* Close the picker
|
|
492
|
+
* @returns {dateTimePicker} chains
|
|
493
|
+
* @fires dateTimePicker#close
|
|
422
494
|
*/
|
|
495
|
+
close: function close() {
|
|
496
|
+
if (this.is('ready')) {
|
|
497
|
+
this.picker.close();
|
|
498
|
+
}
|
|
423
499
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
* Get the current value
|
|
427
|
-
* @returns {String} the field value, null if none
|
|
428
|
-
*/
|
|
429
|
-
getValue: function getValue() {
|
|
430
|
-
if (this.is('rendered')) {
|
|
431
|
-
return this.controls.input.value;
|
|
432
|
-
}
|
|
500
|
+
return this;
|
|
501
|
+
},
|
|
433
502
|
|
|
434
|
-
|
|
435
|
-
|
|
503
|
+
/**
|
|
504
|
+
* Clear the field content and close the picker
|
|
505
|
+
* @returns {dateTimePicker} chains
|
|
506
|
+
* @fires dateTimePicker#close
|
|
507
|
+
* @fires dateTimePicker#clear
|
|
508
|
+
*/
|
|
509
|
+
clear: function clear() {
|
|
510
|
+
if (this.is('ready')) {
|
|
511
|
+
value = '';
|
|
512
|
+
this.picker.close();
|
|
513
|
+
this.picker.clear();
|
|
514
|
+
/**
|
|
515
|
+
* The picker get cleared
|
|
516
|
+
* @event dateTimePicker#clear
|
|
517
|
+
*/
|
|
436
518
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
* @param {String|Date} newValue - the new value matching the format
|
|
440
|
-
*/
|
|
441
|
-
setValue: function setValue(newValue) {
|
|
442
|
-
if (this.is('ready')) {
|
|
443
|
-
value = newValue;
|
|
519
|
+
this.trigger('clear');
|
|
520
|
+
}
|
|
444
521
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
522
|
+
return this;
|
|
523
|
+
},
|
|
448
524
|
|
|
449
|
-
|
|
450
|
-
|
|
525
|
+
/**
|
|
526
|
+
* Clear the field content and close the picker
|
|
527
|
+
* @returns {dateTimePicker} chains
|
|
528
|
+
* @fires dateTimePicker#open
|
|
529
|
+
* @fires dateTimePicker#close
|
|
530
|
+
*/
|
|
531
|
+
toggle: function toogle() {
|
|
532
|
+
if (this.is('ready')) {
|
|
533
|
+
this.picker.toggle();
|
|
534
|
+
}
|
|
451
535
|
|
|
452
|
-
|
|
453
|
-
|
|
536
|
+
return this;
|
|
537
|
+
},
|
|
454
538
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
539
|
+
/**
|
|
540
|
+
* Update constraints on a running instance
|
|
541
|
+
* @param {String} constraint - the constraint name in minDate, maxDate, enable, disable
|
|
542
|
+
* @param {*} constraintValue - the constraint value to update
|
|
543
|
+
* @returns {dateTimePicker} chains
|
|
544
|
+
* @fires dateTimePicker#open
|
|
545
|
+
* @fires dateTimePicker#close
|
|
546
|
+
*/
|
|
547
|
+
updateConstraints: function updateConstraints(constraint, constraintValue) {
|
|
548
|
+
if (this.is('ready')) {
|
|
549
|
+
if (_.contains(supportedConstraints, constraint)) {
|
|
550
|
+
this.picker.set(constraint, constraintValue);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
462
553
|
|
|
463
|
-
|
|
464
|
-
|
|
554
|
+
return this;
|
|
555
|
+
}
|
|
556
|
+
}, defaultConfig);
|
|
557
|
+
dateTimePicker.setTemplate(dateTimePickerTpl).on('init', function () {
|
|
558
|
+
var self = this;
|
|
559
|
+
var locale;
|
|
560
|
+
var setup = setups[this.config.setup] || setups.datetime; //map the locale from the options to the picker locale
|
|
561
|
+
|
|
562
|
+
if (this.config.locale && hasTranslationsForLocale(this.config.locale)) {
|
|
563
|
+
locale = this.config.locale;
|
|
564
|
+
} //date/time format
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
if (locale && this.config.useLocalizedFormat) {
|
|
568
|
+
//get the format from the locale
|
|
569
|
+
format = getLongLocalizedFormat(locale, setup.format.localized);
|
|
570
|
+
} else {
|
|
571
|
+
//get the format from the config
|
|
572
|
+
format = this.config.format || setup.format.default;
|
|
573
|
+
} //input field configuration
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
this.config.field = this.config.field || {}; // replace a field by the date picker input field
|
|
577
|
+
//TODO consider replacing data-attr and classes
|
|
578
|
+
|
|
579
|
+
if (this.config.replaceField && this.config.replaceField instanceof HTMLInputElement) {
|
|
580
|
+
this.config.field.id = this.config.replaceField.id;
|
|
581
|
+
this.config.field.name = this.config.replaceField.name;
|
|
582
|
+
this.config.field.placeholder = this.config.replaceField.placeholder;
|
|
583
|
+
this.config.field.value = this.config.replaceField.value;
|
|
584
|
+
this.config.field.pattern = this.config.replaceField.pattern;
|
|
585
|
+
this.config.replaceField.parentNode.removeChild(this.config.replaceField);
|
|
586
|
+
}
|
|
465
587
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
588
|
+
if (!this.config.field.placeholder && format && setup.mode === 'single') {
|
|
589
|
+
this.config.field.placeholder = format.toLowerCase();
|
|
590
|
+
}
|
|
469
591
|
|
|
470
|
-
|
|
471
|
-
|
|
592
|
+
if (!this.config.field.label) {
|
|
593
|
+
this.config.field.label = setup.label;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Build the configuration of the picker
|
|
597
|
+
* @see https://flatpickr.js.org/options/
|
|
598
|
+
*/
|
|
472
599
|
|
|
473
|
-
return false;
|
|
474
|
-
},
|
|
475
600
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
601
|
+
this.pickerConfig = {
|
|
602
|
+
mode: setup.mode,
|
|
603
|
+
enableTime: !!setup.enableTime,
|
|
604
|
+
noCalendar: !!setup.noCalendar,
|
|
605
|
+
time_24hr: !isFormatAmPm(format),
|
|
606
|
+
enableSeconds: setup.enableTime && isFormatInSeconds(format),
|
|
607
|
+
allowInput: true,
|
|
608
|
+
clickOpens: !this.config.controlButtons,
|
|
609
|
+
disableMobile: true,
|
|
483
610
|
|
|
484
611
|
/**
|
|
485
|
-
*
|
|
486
|
-
* @
|
|
487
|
-
* @
|
|
612
|
+
* How flatpickr will format the given date
|
|
613
|
+
* @param {Date} date
|
|
614
|
+
* @returns {String} the formatted date
|
|
488
615
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
this.picker.open();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
return this;
|
|
616
|
+
formatDate: function formatDate(date) {
|
|
617
|
+
return moment(date).format(format);
|
|
495
618
|
},
|
|
496
619
|
|
|
497
620
|
/**
|
|
498
|
-
*
|
|
499
|
-
* @
|
|
500
|
-
* @
|
|
621
|
+
* How flatpickr parse the given input
|
|
622
|
+
* @param {String} dateString
|
|
623
|
+
* @returns {Date}
|
|
501
624
|
*/
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
this.picker.close();
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
return this;
|
|
625
|
+
parseDate: function parseDate(dateString) {
|
|
626
|
+
return moment(dateString, format).toDate();
|
|
508
627
|
},
|
|
509
628
|
|
|
510
629
|
/**
|
|
511
|
-
*
|
|
512
|
-
* @
|
|
513
|
-
* @fires dateTimePicker#close
|
|
514
|
-
* @fires dateTimePicker#clear
|
|
630
|
+
* When the picker is opened
|
|
631
|
+
* @fires dateTimePicker#open
|
|
515
632
|
*/
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
* The picker get cleared
|
|
523
|
-
* @event dateTimePicker#clear
|
|
524
|
-
*/
|
|
525
|
-
|
|
526
|
-
this.trigger('clear');
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
return this;
|
|
633
|
+
onOpen: function onOpen() {
|
|
634
|
+
/**
|
|
635
|
+
* The picker get opened
|
|
636
|
+
* @event dateTimePicker#open
|
|
637
|
+
*/
|
|
638
|
+
self.trigger('open');
|
|
530
639
|
},
|
|
531
640
|
|
|
532
641
|
/**
|
|
533
|
-
*
|
|
534
|
-
* @returns {dateTimePicker} chains
|
|
535
|
-
* @fires dateTimePicker#open
|
|
642
|
+
* When the picker is opened
|
|
536
643
|
* @fires dateTimePicker#close
|
|
537
644
|
*/
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
645
|
+
onClose: function onClose() {
|
|
646
|
+
/**
|
|
647
|
+
* The picker get closed
|
|
648
|
+
* @event dateTimePicker#close
|
|
649
|
+
*/
|
|
650
|
+
self.trigger('close');
|
|
544
651
|
},
|
|
545
652
|
|
|
546
653
|
/**
|
|
547
|
-
*
|
|
548
|
-
* @param {
|
|
549
|
-
* @param {*} constraintValue - the constraint value to update
|
|
550
|
-
* @returns {dateTimePicker} chains
|
|
551
|
-
* @fires dateTimePicker#open
|
|
552
|
-
* @fires dateTimePicker#close
|
|
654
|
+
* Hook flatpickr error handler
|
|
655
|
+
* @param {Error} err - the thrown error
|
|
553
656
|
*/
|
|
554
|
-
|
|
555
|
-
if (
|
|
556
|
-
if
|
|
557
|
-
|
|
657
|
+
errorHandler: function errorHandler(err) {
|
|
658
|
+
if (err instanceof Error) {
|
|
659
|
+
//if an invalid date is provided
|
|
660
|
+
//add a visual feedback indicating why the field get emptied
|
|
661
|
+
if (/^Invalid date/.test(err.message)) {
|
|
662
|
+
self.controls.input.classList.add('error');
|
|
663
|
+
|
|
664
|
+
_.delay(function () {
|
|
665
|
+
self.controls.input.classList.remove('error');
|
|
666
|
+
}, 1000);
|
|
667
|
+
} else {
|
|
668
|
+
/**
|
|
669
|
+
* Unexpected error
|
|
670
|
+
* @event dateTimePicker#error
|
|
671
|
+
* @param {Error} err
|
|
672
|
+
*/
|
|
673
|
+
self.trigger('error', err);
|
|
558
674
|
}
|
|
559
675
|
}
|
|
560
|
-
|
|
561
|
-
return this;
|
|
562
676
|
}
|
|
563
|
-
}
|
|
564
|
-
dateTimePicker.setTemplate(dateTimePickerTpl).on('init', function () {
|
|
565
|
-
var self = this;
|
|
566
|
-
var locale;
|
|
567
|
-
var setup = setups[this.config.setup] || setups.datetime; //map the locale from the options to the picker locale
|
|
568
|
-
|
|
569
|
-
if (this.config.locale && hasTranslationsForLocale(this.config.locale)) {
|
|
570
|
-
locale = this.config.locale;
|
|
571
|
-
} //date/time format
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
if (locale && this.config.useLocalizedFormat) {
|
|
575
|
-
//get the format from the locale
|
|
576
|
-
format = getLongLocalizedFormat(locale, setup.format.localized);
|
|
577
|
-
} else {
|
|
578
|
-
//get the format from the config
|
|
579
|
-
format = this.config.format || setup.format.default;
|
|
580
|
-
} //input field configuration
|
|
581
|
-
|
|
677
|
+
}; //locale should be defined only if set...
|
|
582
678
|
|
|
583
|
-
|
|
584
|
-
|
|
679
|
+
if (locale) {
|
|
680
|
+
this.pickerConfig.locale = locale;
|
|
681
|
+
}
|
|
585
682
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
this.config.field.placeholder = this.config.replaceField.placeholder;
|
|
590
|
-
this.config.field.value = this.config.replaceField.value;
|
|
591
|
-
this.config.field.pattern = this.config.replaceField.pattern;
|
|
592
|
-
this.config.replaceField.parentNode.removeChild(this.config.replaceField);
|
|
683
|
+
_.forEach(this.config.constraints, function (constraintValue, constraint) {
|
|
684
|
+
if (_.contains(supportedConstraints, constraint) && constraintValue) {
|
|
685
|
+
self.pickerConfig[constraint] = constraintValue;
|
|
593
686
|
}
|
|
687
|
+
}); //render into the container
|
|
594
688
|
|
|
595
|
-
if (!this.config.field.placeholder && format && setup.mode === 'single') {
|
|
596
|
-
this.config.field.placeholder = format.toLowerCase();
|
|
597
|
-
}
|
|
598
689
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
* How flatpickr parse the given input
|
|
629
|
-
* @param {String} dateString
|
|
630
|
-
* @returns {Date}
|
|
631
|
-
*/
|
|
632
|
-
parseDate: function parseDate(dateString) {
|
|
633
|
-
return moment(dateString, format).toDate();
|
|
634
|
-
},
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* When the picker is opened
|
|
638
|
-
* @fires dateTimePicker#open
|
|
639
|
-
*/
|
|
640
|
-
onOpen: function onOpen() {
|
|
641
|
-
/**
|
|
642
|
-
* The picker get opened
|
|
643
|
-
* @event dateTimePicker#open
|
|
644
|
-
*/
|
|
645
|
-
self.trigger('open');
|
|
646
|
-
},
|
|
690
|
+
if (container) {
|
|
691
|
+
setTimeout(function () {
|
|
692
|
+
self.render(container);
|
|
693
|
+
}, 0);
|
|
694
|
+
}
|
|
695
|
+
}).on('render', function () {
|
|
696
|
+
var self = this;
|
|
697
|
+
var element = this.getElement()[0];
|
|
698
|
+
this.controls = {
|
|
699
|
+
input: element.querySelector('input')
|
|
700
|
+
}; //always scope the picker to the component container
|
|
701
|
+
//in order to scope and style each instance
|
|
702
|
+
|
|
703
|
+
this.pickerConfig.appendTo = element; //behavior of the right buttons if configured
|
|
704
|
+
|
|
705
|
+
if (this.config.controlButtons) {
|
|
706
|
+
this.controls.toggleButton = element.querySelector('.picker-toggle');
|
|
707
|
+
this.controls.clearButton = element.querySelector('.picker-clear');
|
|
708
|
+
this.controls.toggleButton.addEventListener('click', function (e) {
|
|
709
|
+
e.preventDefault();
|
|
710
|
+
e.stopPropagation();
|
|
711
|
+
self.toggle();
|
|
712
|
+
});
|
|
713
|
+
this.controls.clearButton.addEventListener('click', function (e) {
|
|
714
|
+
e.preventDefault();
|
|
715
|
+
e.stopPropagation();
|
|
716
|
+
self.clear();
|
|
717
|
+
});
|
|
718
|
+
}
|
|
647
719
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
* @fires dateTimePicker#close
|
|
651
|
-
*/
|
|
652
|
-
onClose: function onClose() {
|
|
653
|
-
/**
|
|
654
|
-
* The picker get closed
|
|
655
|
-
* @event dateTimePicker#close
|
|
656
|
-
*/
|
|
657
|
-
self.trigger('close');
|
|
658
|
-
},
|
|
720
|
+
this.controls.input.addEventListener('change', function () {
|
|
721
|
+
var newValue = self.controls.input.value;
|
|
659
722
|
|
|
723
|
+
if (value && _.isString(newValue) && _.isEmpty(newValue)) {
|
|
724
|
+
//if someone remove the value from the field
|
|
725
|
+
//it's considered a property clean (resets everything)
|
|
726
|
+
self.clear();
|
|
727
|
+
} else if (value !== newValue) {
|
|
728
|
+
value = newValue;
|
|
660
729
|
/**
|
|
661
|
-
*
|
|
662
|
-
* @
|
|
730
|
+
* A value get changed
|
|
731
|
+
* @event dateTimePicker#change
|
|
732
|
+
* @param {String} value - the date/time value
|
|
663
733
|
*/
|
|
664
|
-
errorHandler: function errorHandler(err) {
|
|
665
|
-
if (err instanceof Error) {
|
|
666
|
-
//if an invalid date is provided
|
|
667
|
-
//add a visual feedback indicating why the field get emptied
|
|
668
|
-
if (/^Invalid date/.test(err.message)) {
|
|
669
|
-
self.controls.input.classList.add('error');
|
|
670
|
-
|
|
671
|
-
_.delay(function () {
|
|
672
|
-
self.controls.input.classList.remove('error');
|
|
673
|
-
}, 1000);
|
|
674
|
-
} else {
|
|
675
|
-
/**
|
|
676
|
-
* Unexpected error
|
|
677
|
-
* @event dateTimePicker#error
|
|
678
|
-
* @param {Error} err
|
|
679
|
-
*/
|
|
680
|
-
self.trigger('error', err);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}; //locale should be defined only if set...
|
|
685
734
|
|
|
686
|
-
|
|
687
|
-
this.pickerConfig.locale = locale;
|
|
735
|
+
self.trigger('change', value);
|
|
688
736
|
}
|
|
737
|
+
});
|
|
738
|
+
value = this.controls.input.value; //instantiate the picker
|
|
689
739
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
if (container) {
|
|
698
|
-
setTimeout(function () {
|
|
699
|
-
self.render(container);
|
|
700
|
-
}, 0);
|
|
701
|
-
}
|
|
702
|
-
}).on('render', function () {
|
|
703
|
-
var self = this;
|
|
704
|
-
var element = this.getElement()[0];
|
|
705
|
-
this.controls = {
|
|
706
|
-
input: element.querySelector('input')
|
|
707
|
-
}; //always scope the picker to the component container
|
|
708
|
-
//in order to scope and style each instance
|
|
709
|
-
|
|
710
|
-
this.pickerConfig.appendTo = element; //behavior of the right buttons if configured
|
|
740
|
+
_.defer(function () {
|
|
741
|
+
self.picker = flatpickr(self.controls.input, self.pickerConfig);
|
|
742
|
+
self.enable().setState('ready', true).trigger('ready');
|
|
743
|
+
});
|
|
744
|
+
}).on('enable', function () {
|
|
745
|
+
if (this.controls) {
|
|
746
|
+
this.controls.input.disabled = false;
|
|
711
747
|
|
|
712
748
|
if (this.config.controlButtons) {
|
|
713
|
-
this.controls.toggleButton =
|
|
714
|
-
this.controls.clearButton =
|
|
715
|
-
this.controls.toggleButton.addEventListener('click', function (e) {
|
|
716
|
-
e.preventDefault();
|
|
717
|
-
e.stopPropagation();
|
|
718
|
-
self.toggle();
|
|
719
|
-
});
|
|
720
|
-
this.controls.clearButton.addEventListener('click', function (e) {
|
|
721
|
-
e.preventDefault();
|
|
722
|
-
e.stopPropagation();
|
|
723
|
-
self.clear();
|
|
724
|
-
});
|
|
749
|
+
this.controls.toggleButton.disabled = false;
|
|
750
|
+
this.controls.clearButton.disabled = false;
|
|
725
751
|
}
|
|
752
|
+
}
|
|
753
|
+
}).on('disable', function () {
|
|
754
|
+
if (this.controls) {
|
|
755
|
+
this.controls.input.disabled = true;
|
|
726
756
|
|
|
727
|
-
this.
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
if (value && _.isString(newValue) && _.isEmpty(newValue)) {
|
|
731
|
-
//if someone remove the value from the field
|
|
732
|
-
//it's considered a property clean (resets everything)
|
|
733
|
-
self.clear();
|
|
734
|
-
} else if (value !== newValue) {
|
|
735
|
-
value = newValue;
|
|
736
|
-
/**
|
|
737
|
-
* A value get changed
|
|
738
|
-
* @event dateTimePicker#change
|
|
739
|
-
* @param {String} value - the date/time value
|
|
740
|
-
*/
|
|
741
|
-
|
|
742
|
-
self.trigger('change', value);
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
value = this.controls.input.value; //instantiate the picker
|
|
746
|
-
|
|
747
|
-
_.defer(function () {
|
|
748
|
-
self.picker = flatpickr(self.controls.input, self.pickerConfig);
|
|
749
|
-
self.enable().setState('ready', true).trigger('ready');
|
|
750
|
-
});
|
|
751
|
-
}).on('enable', function () {
|
|
752
|
-
if (this.controls) {
|
|
753
|
-
this.controls.input.disabled = false;
|
|
754
|
-
|
|
755
|
-
if (this.config.controlButtons) {
|
|
756
|
-
this.controls.toggleButton.disabled = false;
|
|
757
|
-
this.controls.clearButton.disabled = false;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}).on('disable', function () {
|
|
761
|
-
if (this.controls) {
|
|
762
|
-
this.controls.input.disabled = true;
|
|
763
|
-
|
|
764
|
-
if (this.config.controlButtons) {
|
|
765
|
-
this.controls.toggleButton.disabled = true;
|
|
766
|
-
this.controls.clearButton.disabled = true;
|
|
767
|
-
}
|
|
757
|
+
if (this.config.controlButtons) {
|
|
758
|
+
this.controls.toggleButton.disabled = true;
|
|
759
|
+
this.controls.clearButton.disabled = true;
|
|
768
760
|
}
|
|
769
|
-
}
|
|
761
|
+
}
|
|
762
|
+
}); //defered init to catch the event
|
|
770
763
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
764
|
+
setTimeout(function () {
|
|
765
|
+
dateTimePicker.init(options);
|
|
766
|
+
}, 0);
|
|
767
|
+
return dateTimePicker;
|
|
768
|
+
}
|
|
776
769
|
|
|
777
|
-
|
|
770
|
+
return dateTimePickerFactory;
|
|
778
771
|
|
|
779
772
|
});
|