@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.
Files changed (233) hide show
  1. package/dist/actionbar.js +386 -395
  2. package/dist/adder.js +21 -19
  3. package/dist/animable/absorbable/absorbable.js +204 -213
  4. package/dist/animable/absorbable/css/absorb.css +1 -0
  5. package/dist/animable/absorbable/css/absorb.css.map +1 -1
  6. package/dist/animable/pulsable/pulsable.js +168 -177
  7. package/dist/autocomplete/css/autocomplete.css +1 -0
  8. package/dist/autocomplete/css/autocomplete.css.map +1 -1
  9. package/dist/autocomplete.js +68 -66
  10. package/dist/badge/badge.js +188 -197
  11. package/dist/badge/css/badge.css +1 -0
  12. package/dist/badge/css/badge.css.map +1 -1
  13. package/dist/breadcrumbs.js +275 -284
  14. package/dist/btngrouper.js +5 -5
  15. package/dist/bulkActionPopup.js +490 -495
  16. package/dist/button.js +283 -291
  17. package/dist/cascadingComboBox.js +249 -258
  18. package/dist/ckeditor/ckConfigurator.js +26 -19
  19. package/dist/ckeditor/dtdHandler.js +11 -9
  20. package/dist/class/selector.js +441 -450
  21. package/dist/component/resizable.js +1 -1
  22. package/dist/component/windowed.js +285 -294
  23. package/dist/component.js +419 -428
  24. package/dist/contextualPopup.js +417 -426
  25. package/dist/dashboard.js +300 -309
  26. package/dist/datalist.js +753 -762
  27. package/dist/datatable/filterStrategy/multiple.js +1 -1
  28. package/dist/datatable/filterStrategy/single.js +1 -1
  29. package/dist/datatable.js +1527 -1550
  30. package/dist/dateRange/dateRange.js +393 -402
  31. package/dist/datetime/picker.js +665 -672
  32. package/dist/deleter.js +368 -377
  33. package/dist/destination/selector.js +286 -295
  34. package/dist/dialog/alert.js +3 -3
  35. package/dist/dialog/confirm.js +1 -1
  36. package/dist/dialog/confirmDelete.js +216 -225
  37. package/dist/dialog.js +650 -654
  38. package/dist/disabler.js +8 -8
  39. package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
  40. package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
  41. package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
  42. package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
  43. package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
  44. package/dist/documentViewer/providers/pdfViewer.js +184 -193
  45. package/dist/documentViewer.js +292 -301
  46. package/dist/dropdown.js +383 -392
  47. package/dist/durationer.js +5 -5
  48. package/dist/dynamicComponent.js +597 -598
  49. package/dist/feedback.js +356 -362
  50. package/dist/figure/FigureStateActive.js +117 -108
  51. package/dist/filesender.js +2 -2
  52. package/dist/filter.js +230 -239
  53. package/dist/form/dropdownForm.js +355 -357
  54. package/dist/form/form.js +919 -690
  55. package/dist/form/simpleForm.js +1 -1
  56. package/dist/form/validator/renderer.js +233 -235
  57. package/dist/form/validator/validator.js +257 -189
  58. package/dist/form/widget/definitions.js +1 -1
  59. package/dist/form/widget/providers/checkBox.js +254 -259
  60. package/dist/form/widget/providers/comboBox.js +187 -192
  61. package/dist/form/widget/providers/default.js +8 -9
  62. package/dist/form/widget/providers/hidden.js +170 -179
  63. package/dist/form/widget/providers/hiddenBox.js +262 -267
  64. package/dist/form/widget/providers/radioBox.js +216 -225
  65. package/dist/form/widget/providers/textArea.js +187 -196
  66. package/dist/form/widget/providers/textBox.js +2 -3
  67. package/dist/form/widget/widget.js +473 -475
  68. package/dist/formValidator/formValidator.js +1 -1
  69. package/dist/formValidator/highlighters/message.js +1 -1
  70. package/dist/generis/form/form.js +314 -323
  71. package/dist/generis/validator/validator.js +209 -218
  72. package/dist/generis/widget/checkBox/checkBox.js +218 -227
  73. package/dist/generis/widget/comboBox/comboBox.js +179 -188
  74. package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
  75. package/dist/generis/widget/textBox/textBox.js +169 -178
  76. package/dist/generis/widget/widget.js +246 -255
  77. package/dist/groupedComboBox.js +222 -231
  78. package/dist/groupvalidator.js +2 -2
  79. package/dist/highlighter.js +967 -958
  80. package/dist/image/ImgStateActive/helper.js +7 -5
  81. package/dist/image/ImgStateActive/initHelper.js +49 -43
  82. package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
  83. package/dist/image/ImgStateActive/mediaSizer.js +14 -12
  84. package/dist/image/ImgStateActive.js +72 -70
  85. package/dist/incrementer.js +6 -6
  86. package/dist/inplacer.js +6 -6
  87. package/dist/itemButtonList/css/item-button-list.css +1 -0
  88. package/dist/itemButtonList/css/item-button-list.css.map +1 -1
  89. package/dist/itemButtonList.js +439 -435
  90. package/dist/keyNavigation/navigableDomElement.js +51 -38
  91. package/dist/keyNavigation/navigator.js +85 -70
  92. package/dist/listbox.js +460 -469
  93. package/dist/liststyler.js +8 -8
  94. package/dist/loadingButton/loadingButton.js +209 -218
  95. package/dist/lock.js +476 -485
  96. package/dist/login/login.js +475 -484
  97. package/dist/maths/calculator/basicCalculator.js +235 -244
  98. package/dist/maths/calculator/calculatorComponent.js +3 -3
  99. package/dist/maths/calculator/core/board.js +772 -781
  100. package/dist/maths/calculator/core/expression.js +476 -485
  101. package/dist/maths/calculator/core/labels.js +228 -237
  102. package/dist/maths/calculator/core/tokenizer.js +1 -1
  103. package/dist/maths/calculator/core/tokens.js +163 -170
  104. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
  105. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
  106. package/dist/maths/calculator/scientificCalculator.js +327 -336
  107. package/dist/mediaEditor/mediaEditorComponent.js +238 -245
  108. package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
  109. package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
  110. package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
  111. package/dist/mediaplayer/players/html5.js +666 -675
  112. package/dist/mediaplayer/players/youtube.js +419 -424
  113. package/dist/mediaplayer/support.js +11 -10
  114. package/dist/mediaplayer/utils/reminder.js +14 -13
  115. package/dist/mediaplayer/utils/timeObserver.js +10 -11
  116. package/dist/mediaplayer/youtubeManager.js +164 -145
  117. package/dist/mediaplayer.js +1565 -1520
  118. package/dist/mediasizer.js +669 -678
  119. package/dist/modal.js +10 -17
  120. package/dist/pageSizeSelector.js +219 -228
  121. package/dist/pagination/providers/pages.js +280 -289
  122. package/dist/pagination/providers/simple.js +192 -201
  123. package/dist/previewer.js +30 -30
  124. package/dist/progressbar.js +4 -4
  125. package/dist/report.js +347 -356
  126. package/dist/resource/filters.js +271 -280
  127. package/dist/resource/list.js +1264 -1273
  128. package/dist/resource/selector.js +865 -874
  129. package/dist/resource/tree.js +1483 -1492
  130. package/dist/resourcemgr/fileBrowser.js +564 -569
  131. package/dist/resourcemgr/filePreview.js +16 -16
  132. package/dist/resourcemgr/fileSelector.js +515 -524
  133. package/dist/resourcemgr/util/updatePermissions.js +2 -2
  134. package/dist/resourcemgr.js +306 -315
  135. package/dist/searchModal/advancedSearch.js +796 -767
  136. package/dist/searchModal.js +114 -91
  137. package/dist/switch/switch.js +298 -307
  138. package/dist/tabs.js +598 -575
  139. package/dist/taskQueue/status.js +312 -321
  140. package/dist/taskQueue/table.js +375 -384
  141. package/dist/taskQueue/taskQueueModel.js +488 -472
  142. package/dist/taskQueueButton/taskable.js +264 -273
  143. package/dist/taskQueueButton/treeButton.js +189 -198
  144. package/dist/themeLoader.js +24 -23
  145. package/dist/themes.js +1 -1
  146. package/dist/toggler.js +3 -3
  147. package/dist/tooltip.js +295 -304
  148. package/dist/transformer.js +2 -2
  149. package/dist/tristateCheckboxGroup.js +311 -320
  150. package/dist/uploader.js +687 -696
  151. package/dist/validator/Report.js +1 -1
  152. package/dist/validator/Validator.js +3 -3
  153. package/dist/validator/validators.js +9 -9
  154. package/dist/validator.js +240 -230
  155. package/dist/waitForMedia.js +1 -1
  156. package/package.json +3 -3
  157. package/src/animable/absorbable/css/absorb.css +1 -0
  158. package/src/animable/absorbable/css/absorb.css.map +1 -1
  159. package/src/autocomplete/css/autocomplete.css +1 -0
  160. package/src/autocomplete/css/autocomplete.css.map +1 -1
  161. package/src/badge/css/badge.css +1 -0
  162. package/src/badge/css/badge.css.map +1 -1
  163. package/src/ckeditor/ckConfigurator.js +4 -0
  164. package/src/itemButtonList/css/item-button-list.css +1 -0
  165. package/src/itemButtonList/css/item-button-list.css.map +1 -1
  166. package/src/.DS_Store +0 -0
  167. package/src/css/basic.css +0 -7826
  168. package/src/css/basic.css.map +0 -1
  169. package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
  170. package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
  171. package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
  172. package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
  173. package/src/scss/.DS_Store +0 -0
  174. package/src/scss/basic.scss +0 -16
  175. package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
  176. package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
  177. package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
  178. package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
  179. package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
  180. package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
  181. package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
  182. package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
  183. package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
  184. package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
  185. package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
  186. package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
  187. package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
  188. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
  189. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
  190. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
  191. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
  192. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
  193. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
  194. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
  195. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
  196. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
  197. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
  198. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
  199. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
  200. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
  201. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
  202. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
  203. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
  204. package/src/scss/font/tao/tao.eot +0 -0
  205. package/src/scss/font/tao/tao.svg +0 -235
  206. package/src/scss/font/tao/tao.ttf +0 -0
  207. package/src/scss/font/tao/tao.woff +0 -0
  208. package/src/scss/inc/_base.scss +0 -496
  209. package/src/scss/inc/_bootstrap.scss +0 -6
  210. package/src/scss/inc/_buttons.scss +0 -114
  211. package/src/scss/inc/_colors.scss +0 -88
  212. package/src/scss/inc/_feedback.scss +0 -150
  213. package/src/scss/inc/_flex-grid.scss +0 -15
  214. package/src/scss/inc/_fonts.scss +0 -4
  215. package/src/scss/inc/_forms.scss +0 -827
  216. package/src/scss/inc/_functions.scss +0 -283
  217. package/src/scss/inc/_grid.scss +0 -66
  218. package/src/scss/inc/_jquery.nouislider.scss +0 -254
  219. package/src/scss/inc/_normalize.scss +0 -528
  220. package/src/scss/inc/_report.scss +0 -68
  221. package/src/scss/inc/_secondary-properties.scss +0 -89
  222. package/src/scss/inc/_select2.scss +0 -634
  223. package/src/scss/inc/_toolbars.scss +0 -155
  224. package/src/scss/inc/_tooltip.scss +0 -312
  225. package/src/scss/inc/_variables.scss +0 -21
  226. package/src/scss/inc/base/_highlight.scss +0 -5
  227. package/src/scss/inc/base/_list-style.scss +0 -59
  228. package/src/scss/inc/base/_svg.scss +0 -3
  229. package/src/scss/inc/base/_table.scss +0 -63
  230. package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
  231. package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
  232. package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
  233. package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
@@ -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
- _ = _ && 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
-
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
- * This program is free software; you can redistribute it and/or
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
- hb.registerHelper('dompurify', function (context) {
45
- return DOMPurify.sanitize(context);
46
- });
47
- /**
48
- * Register join helper
49
- *
50
- * Example :
51
- * var values = {a:v1, b:v2, c:v3};
52
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
53
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
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
- _.forIn(arr, function (value, key) {
63
- var fragment = '';
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
- if (value !== null || value !== undefined) {
66
- if (typeof value === 'boolean') {
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
- if (keyValueGlue !== undefined) {
76
- fragment += key + keyValueGlue;
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
- fragment += wrapper + value + wrapper;
80
- fragments.push(fragment);
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
- return ret;
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
- hb.registerHelper('property', function (name, context) {
111
- return context[name] || '';
112
- }); // register an 'includes' helper
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
- hb.registerHelper('includes', function (haystack, needle, options) {
116
- if (_.contains(haystack, needle)) {
117
- return options.fn(this);
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
- if (!Helpers0.__initialized) {
123
- Helpers0(Handlebars);
124
- Helpers0.__initialized = true;
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
- function program3(depth0,data) {
138
-
139
- var buffer = "", stack1;
140
- buffer += "id=\""
141
- + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
142
- + "\"";
143
- return buffer;
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 program5(depth0,data) {
147
-
148
- var buffer = "", stack1;
149
- buffer += "name=\""
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 program7(depth0,data) {
156
-
157
- var buffer = "", stack1;
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
- function program9(depth0,data) {
165
-
166
- var buffer = "", stack1;
167
- buffer += "placeholder=\""
168
- + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.placeholder)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
169
- + "\"";
170
- return buffer;
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
- function program11(depth0,data) {
174
-
175
- var buffer = "", stack1;
176
- buffer += "pattern=\""
177
- + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.pattern)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
178
- + "\"";
179
- return buffer;
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
- function program13(depth0,data) {
183
-
184
- var buffer = "", stack1;
185
- buffer += "aria-label=\""
186
- + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.field)),stack1 == null || stack1 === false ? stack1 : stack1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
187
- + "\"";
188
- return buffer;
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
- function program15(depth0,data) {
192
-
193
- var buffer = "", helper, options;
194
- buffer += "\n <button type=\"button\" disabled class=\"picker-toggle\" title=\""
195
- + 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)))
196
- + "\" aria-label=\""
197
- + 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)))
198
- + "\" >\n <span class=\"icon-calendar\" role=\"img\"></span>\n </button>\n <button type=\"button\" disabled class=\"picker-clear\" title=\""
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
- buffer += "<div class=\"datetime-picker ";
207
- if (helper = helpers.setup) { stack1 = helper.call(depth0, {hash:{},data:data}); }
208
- else { helper = (depth0 && depth0.setup); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
209
- buffer += escapeExpression(stack1)
210
- + " ";
211
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.controlButtons), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
212
- if(stack1 || stack1 === 0) { buffer += stack1; }
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
- * This program is free software; you can redistribute it and/or
244
- * modify it under the terms of the GNU General Public License
245
- * as published by the Free Software Foundation; under version 2
246
- * of the License (non-upgradable).
247
- *
248
- * This program is distributed in the hope that it will be useful,
249
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
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
- var formats = {
265
- date: {
266
- default: 'YYYY-MM-DD',
267
- localized: 'L'
268
- },
269
- time: {
270
- default: 'HH:mm',
271
- localized: 'LT'
272
- },
273
- datetime: {
274
- default: 'YYYY-MM-DD HH:mm',
275
- localized: 'L LT'
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
- var setups = {
283
- 'date-range': {
284
- mode: 'range',
285
- label: __('date range'),
286
- format: formats.date
287
- },
288
- 'datetime-range': {
289
- mode: 'range',
290
- label: __('date time range'),
291
- enableTime: true,
292
- format: formats.datetime
293
- },
294
- date: {
295
- mode: 'single',
296
- format: formats.date
297
- },
298
- time: {
299
- mode: 'single',
300
- enableTime: true,
301
- label: __('time'),
302
- noCalendar: true,
303
- format: formats.time
304
- },
305
- datetime: {
306
- mode: 'single',
307
- enableTime: true,
308
- label: __('date time'),
309
- format: formats.datetime
310
- }
311
- };
312
- /**
313
- * List of supported constraints
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
- var supportedConstraints = ['minDate', 'maxDate', 'enable', 'disable'];
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
- * Checks translation existing for given locale
319
- * @param {String} locale
320
- * @returns {Boolean}
414
+ * @typedef {Object} dateTimePicker
321
415
  */
322
416
 
323
- const hasTranslationsForLocale = locale => _.isObject(flatpickrLocalization[locale]);
324
- /**
325
- * Detects document language
326
- * @returns {String | undefined}
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
- const getDefaultLocale = () => {
331
- const documentLang = window.document.documentElement.getAttribute('lang');
332
- const documentLocale = documentLang && documentLang.split('-')[0];
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
- if (documentLocale && hasTranslationsForLocale(documentLocale)) {
335
- return documentLocale;
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
- var defaultConfig = {
345
- setup: 'date',
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
- var getLongLocalizedFormat = function getLongLocalizedFormat(locale, localizedFormat) {
359
- if (/[LT]+/.test(localizedFormat) && locale) {
360
- return localizedFormat.split(' ').map(function (format) {
361
- return moment(new Date()).locale(locale).localeData().longDateFormat(format);
362
- }).join(' ');
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
- return false;
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
- var isFormatAmPm = function isFormatAmPm(format) {
375
- return format && /a$/i.test(format);
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
- var isFormatInSeconds = function isFormatInSeconds(format) {
385
- return format && /(:ss)+/i.test(format);
386
- };
387
- /**
388
- * The component factory
389
- *
390
- * @param {HTMLElement|jQuery} container - where to append the component
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
- * @typedef {Object} dateTimePicker
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
- var dateTimePicker = component({
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
- return null;
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
- * Set the current value
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
- if (_.isString(value)) {
446
- this.controls.input.value = value;
447
- }
522
+ return this;
523
+ },
448
524
 
449
- this.picker.setDate(value, true);
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
- return null;
453
- },
536
+ return this;
537
+ },
454
538
 
455
- /**
456
- * Get the dates currently selected.
457
- * Usefull for the range mode to get the date list
458
- * @returns {Array<[Date|String]>|boolean} the selected dates
459
- */
460
- getSelectedDates: function getSelectedDates() {
461
- var selection;
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
- if (this.is('ready') && this.picker) {
464
- selection = this.picker.selectedDates;
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
- if (selection && !_.isArray(selection)) {
467
- return [selection];
468
- }
588
+ if (!this.config.field.placeholder && format && setup.mode === 'single') {
589
+ this.config.field.placeholder = format.toLowerCase();
590
+ }
469
591
 
470
- return selection;
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
- * Get the date/time format description, ie. 'YYYY-MM-DD'
478
- * @returns {String} the format
479
- */
480
- getFormat: function getFormat() {
481
- return format;
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
- * Open the picker
486
- * @returns {dateTimePicker} chains
487
- * @fires dateTimePicker#open
612
+ * How flatpickr will format the given date
613
+ * @param {Date} date
614
+ * @returns {String} the formatted date
488
615
  */
489
- open: function open() {
490
- if (this.is('ready')) {
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
- * Close the picker
499
- * @returns {dateTimePicker} chains
500
- * @fires dateTimePicker#close
621
+ * How flatpickr parse the given input
622
+ * @param {String} dateString
623
+ * @returns {Date}
501
624
  */
502
- close: function close() {
503
- if (this.is('ready')) {
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
- * Clear the field content and close the picker
512
- * @returns {dateTimePicker} chains
513
- * @fires dateTimePicker#close
514
- * @fires dateTimePicker#clear
630
+ * When the picker is opened
631
+ * @fires dateTimePicker#open
515
632
  */
516
- clear: function clear() {
517
- if (this.is('ready')) {
518
- value = '';
519
- this.picker.close();
520
- this.picker.clear();
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
- * Clear the field content and close the picker
534
- * @returns {dateTimePicker} chains
535
- * @fires dateTimePicker#open
642
+ * When the picker is opened
536
643
  * @fires dateTimePicker#close
537
644
  */
538
- toggle: function toogle() {
539
- if (this.is('ready')) {
540
- this.picker.toggle();
541
- }
542
-
543
- return this;
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
- * Update constraints on a running instance
548
- * @param {String} constraint - the constraint name in minDate, maxDate, enable, disable
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
- updateConstraints: function updateConstraints(constraint, constraintValue) {
555
- if (this.is('ready')) {
556
- if (_.contains(supportedConstraints, constraint)) {
557
- this.picker.set(constraint, constraintValue);
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
- }, defaultConfig);
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
- this.config.field = this.config.field || {}; // replace a field by the date picker input field
584
- //TODO consider replacing data-attr and classes
679
+ if (locale) {
680
+ this.pickerConfig.locale = locale;
681
+ }
585
682
 
586
- if (this.config.replaceField && this.config.replaceField instanceof HTMLInputElement) {
587
- this.config.field.id = this.config.replaceField.id;
588
- this.config.field.name = this.config.replaceField.name;
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
- if (!this.config.field.label) {
600
- this.config.field.label = setup.label;
601
- }
602
- /**
603
- * Build the configuration of the picker
604
- * @see https://flatpickr.js.org/options/
605
- */
606
-
607
-
608
- this.pickerConfig = {
609
- mode: setup.mode,
610
- enableTime: !!setup.enableTime,
611
- noCalendar: !!setup.noCalendar,
612
- time_24hr: !isFormatAmPm(format),
613
- enableSeconds: setup.enableTime && isFormatInSeconds(format),
614
- allowInput: true,
615
- clickOpens: !this.config.controlButtons,
616
- disableMobile: true,
617
-
618
- /**
619
- * How flatpickr will format the given date
620
- * @param {Date} date
621
- * @returns {String} the formatted date
622
- */
623
- formatDate: function formatDate(date) {
624
- return moment(date).format(format);
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
- * When the picker is opened
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
- * Hook flatpickr error handler
662
- * @param {Error} err - the thrown error
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
- if (locale) {
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
- _.forEach(this.config.constraints, function (constraintValue, constraint) {
691
- if (_.contains(supportedConstraints, constraint) && constraintValue) {
692
- self.pickerConfig[constraint] = constraintValue;
693
- }
694
- }); //render into the container
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 = element.querySelector('.picker-toggle');
714
- this.controls.clearButton = element.querySelector('.picker-clear');
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.controls.input.addEventListener('change', function () {
728
- var newValue = self.controls.input.value;
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
- }); //defered init to catch the event
761
+ }
762
+ }); //defered init to catch the event
770
763
 
771
- setTimeout(function () {
772
- dateTimePicker.init(options);
773
- }, 0);
774
- return dateTimePicker;
775
- }
764
+ setTimeout(function () {
765
+ dateTimePicker.init(options);
766
+ }, 0);
767
+ return dateTimePicker;
768
+ }
776
769
 
777
- return dateTimePickerFactory;
770
+ return dateTimePickerFactory;
778
771
 
779
772
  });