@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,565 +1,563 @@
1
1
  define(['lodash', 'i18n', 'handlebars', 'core/providerRegistry', 'ui/component', 'ui/form/validator/validator', 'ui/form/validator/renderer', 'ui/form/widget/providers/default', 'lib/dompurify/purify', 'css!ui/form/widget/css/widget.css'], function (_, __, Handlebars, providerRegistry, componentFactory, validatorFactory, validatorRendererFactory, defaultProvider, DOMPurify, widget_css) { 'use strict';
2
2
 
3
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
4
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
5
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
6
- providerRegistry = providerRegistry && Object.prototype.hasOwnProperty.call(providerRegistry, 'default') ? providerRegistry['default'] : providerRegistry;
7
- componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
8
- validatorFactory = validatorFactory && Object.prototype.hasOwnProperty.call(validatorFactory, 'default') ? validatorFactory['default'] : validatorFactory;
9
- validatorRendererFactory = validatorRendererFactory && Object.prototype.hasOwnProperty.call(validatorRendererFactory, 'default') ? validatorRendererFactory['default'] : validatorRendererFactory;
10
- defaultProvider = defaultProvider && Object.prototype.hasOwnProperty.call(defaultProvider, 'default') ? defaultProvider['default'] : defaultProvider;
11
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
12
-
3
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
4
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
5
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
6
+ providerRegistry = providerRegistry && Object.prototype.hasOwnProperty.call(providerRegistry, 'default') ? providerRegistry['default'] : providerRegistry;
7
+ componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
8
+ validatorFactory = validatorFactory && Object.prototype.hasOwnProperty.call(validatorFactory, 'default') ? validatorFactory['default'] : validatorFactory;
9
+ validatorRendererFactory = validatorRendererFactory && Object.prototype.hasOwnProperty.call(validatorRendererFactory, 'default') ? validatorRendererFactory['default'] : validatorRendererFactory;
10
+ defaultProvider = defaultProvider && Object.prototype.hasOwnProperty.call(defaultProvider, 'default') ? defaultProvider['default'] : defaultProvider;
11
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
12
+
13
+ function _typeof(obj) {
14
+ "@babel/helpers - typeof";
15
+
16
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
17
+ return typeof obj;
18
+ } : function (obj) {
19
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
20
+ }, _typeof(obj);
21
+ }
22
+
23
+ function Helpers0 (hb) {
24
+ //register a i18n helper
25
+ hb.registerHelper('__', function (key) {
26
+ return __(key);
27
+ });
13
28
  /**
14
- * This program is free software; you can redistribute it and/or
15
- * modify it under the terms of the GNU General Public License
16
- * as published by the Free Software Foundation; under version 2
17
- * of the License (non-upgradable).
18
- *
19
- * This program is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License
25
- * along with this program; if not, write to the Free Software
26
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
- *
28
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
29
- *
29
+ * Register dompurify helper
30
30
  *
31
+ * https://github.com/cure53/DOMPurify
32
+ * with config SAFE_FOR_TEMPLATES: true
33
+ * to make output safe for template systems
31
34
  */
32
- function Helpers0 (hb) {
33
- //register a i18n helper
34
- hb.registerHelper('__', function (key) {
35
- return __(key);
36
- });
37
- /**
38
- * Register dompurify helper
39
- *
40
- * https://github.com/cure53/DOMPurify
41
- * with config SAFE_FOR_TEMPLATES: true
42
- * to make output safe for template systems
43
- */
44
35
 
45
- hb.registerHelper('dompurify', function (context) {
46
- return DOMPurify.sanitize(context);
47
- });
48
- /**
49
- * Register join helper
50
- *
51
- * Example :
52
- * var values = {a:v1, b:v2, c:v3};
53
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
54
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
55
- */
36
+ hb.registerHelper('dompurify', function (context) {
37
+ return DOMPurify.sanitize(context);
38
+ });
39
+ /**
40
+ * Register join helper
41
+ *
42
+ * Example :
43
+ * var values = {a:v1, b:v2, c:v3};
44
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
45
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
46
+ */
56
47
 
57
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
58
- var fragments = [];
59
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
60
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
61
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
48
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
49
+ var fragments = [];
50
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
51
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
52
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
62
53
 
63
- _.forIn(arr, function (value, key) {
64
- var fragment = '';
54
+ _.forIn(arr, function (value, key) {
55
+ var fragment = '';
65
56
 
66
- if (value !== null || value !== undefined) {
67
- if (typeof value === 'boolean') {
68
- value = value ? 'true' : 'false';
69
- } else if (typeof value === 'object') {
70
- value = _.values(value).join(' ');
71
- }
72
- } else {
73
- value = '';
57
+ if (value !== null || value !== undefined) {
58
+ if (typeof value === 'boolean') {
59
+ value = value ? 'true' : 'false';
60
+ } else if (_typeof(value) === 'object') {
61
+ value = _.values(value).join(' ');
74
62
  }
63
+ } else {
64
+ value = '';
65
+ }
75
66
 
76
- if (keyValueGlue !== undefined) {
77
- fragment += key + keyValueGlue;
78
- }
67
+ if (keyValueGlue !== undefined) {
68
+ fragment += key + keyValueGlue;
69
+ }
79
70
 
80
- fragment += wrapper + value + wrapper;
81
- fragments.push(fragment);
82
- });
71
+ fragment += wrapper + value + wrapper;
72
+ fragments.push(fragment);
73
+ });
83
74
 
84
- return fragments.join(fragmentGlue);
85
- }); //register a classic "for loop" helper
86
- //it also adds a local variable "i" as the index in each iteration loop
75
+ return fragments.join(fragmentGlue);
76
+ }); //register a classic "for loop" helper
77
+ //it also adds a local variable "i" as the index in each iteration loop
87
78
 
88
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
89
- var ret = '';
90
- startIndex = parseInt(startIndex);
91
- stopIndex = parseInt(stopIndex);
92
- increment = parseInt(increment);
79
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
80
+ var ret = '';
81
+ startIndex = parseInt(startIndex);
82
+ stopIndex = parseInt(stopIndex);
83
+ increment = parseInt(increment);
93
84
 
94
- for (var i = startIndex; i < stopIndex; i += increment) {
95
- ret += options.fn(_.extend({}, this, {
96
- i: i
97
- }));
98
- }
85
+ for (var i = startIndex; i < stopIndex; i += increment) {
86
+ ret += options.fn(_.extend({}, this, {
87
+ i: i
88
+ }));
89
+ }
99
90
 
100
- return ret;
101
- });
102
- hb.registerHelper('equal', function (var1, var2, options) {
103
- if (var1 == var2) {
104
- return options.fn(this);
105
- } else {
106
- return options.inverse(this);
107
- }
108
- }); // register a "get property" helper
109
- // it gets the named property from the provided context
91
+ return ret;
92
+ });
93
+ hb.registerHelper('equal', function (var1, var2, options) {
94
+ if (var1 == var2) {
95
+ return options.fn(this);
96
+ } else {
97
+ return options.inverse(this);
98
+ }
99
+ }); // register a "get property" helper
100
+ // it gets the named property from the provided context
110
101
 
111
- hb.registerHelper('property', function (name, context) {
112
- return context[name] || '';
113
- }); // register an 'includes' helper
114
- // it checks if value is in array
102
+ hb.registerHelper('property', function (name, context) {
103
+ return context[name] || '';
104
+ }); // register an 'includes' helper
105
+ // it checks if value is in array
115
106
 
116
- hb.registerHelper('includes', function (haystack, needle, options) {
117
- if (_.contains(haystack, needle)) {
118
- return options.fn(this);
119
- }
120
- });
107
+ hb.registerHelper('includes', function (haystack, needle, options) {
108
+ if (_.contains(haystack, needle)) {
109
+ return options.fn(this);
110
+ }
111
+ });
112
+ }
113
+
114
+ if (!Helpers0.__initialized) {
115
+ Helpers0(Handlebars);
116
+ Helpers0.__initialized = true;
117
+ }
118
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
119
+ this.compilerInfo = [4,'>= 1.0.0'];
120
+ helpers = this.merge(helpers, Handlebars.helpers); partials = this.merge(partials, Handlebars.partials); data = data || {};
121
+ var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this;
122
+
123
+ function program1(depth0,data) {
124
+
125
+ var buffer = "", stack1, helper;
126
+ buffer += "type=\"";
127
+ if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
128
+ else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
129
+ buffer += escapeExpression(stack1)
130
+ + "\" ";
131
+ return buffer;
121
132
  }
122
133
 
123
- if (!Helpers0.__initialized) {
124
- Helpers0(Handlebars);
125
- Helpers0.__initialized = true;
134
+ buffer += "<div class=\"form-widget ";
135
+ if (helper = helpers.widgetType) { stack1 = helper.call(depth0, {hash:{},data:data}); }
136
+ else { helper = (depth0 && depth0.widgetType); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
137
+ buffer += escapeExpression(stack1)
138
+ + "\">\n <div class=\"widget-label\">\n ";
139
+ stack1 = self.invokePartial(partials['ui-form-widget-label'], 'ui-form-widget-label', depth0, helpers, partials, data);
140
+ if(stack1 || stack1 === 0) { buffer += stack1; }
141
+ buffer += "\n </div>\n <div class=\"widget-field\">\n <input class=\"widget-input-inline\" ";
142
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.type), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
143
+ if(stack1 || stack1 === 0) { buffer += stack1; }
144
+ buffer += "name=\"";
145
+ if (helper = helpers.uri) { stack1 = helper.call(depth0, {hash:{},data:data}); }
146
+ else { helper = (depth0 && depth0.uri); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
147
+ buffer += escapeExpression(stack1)
148
+ + "\" value=\"";
149
+ if (helper = helpers.value) { stack1 = helper.call(depth0, {hash:{},data:data}); }
150
+ else { helper = (depth0 && depth0.value); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
151
+ buffer += escapeExpression(stack1)
152
+ + "\" />\n </div>\n</div>\n";
153
+ return buffer;
154
+ });
155
+ function widgetTpl(data, options, asString) {
156
+ var html = Template(data, options);
157
+ return (asString || true) ? html : $(html);
158
+ }
159
+
160
+ if (!Helpers0.__initialized) {
161
+ Helpers0(Handlebars);
162
+ Helpers0.__initialized = true;
163
+ }
164
+ var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
165
+ this.compilerInfo = [4,'>= 1.0.0'];
166
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
167
+ var buffer = "", stack1, helper, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, functionType="function", self=this;
168
+
169
+ function program1(depth0,data) {
170
+
171
+ var buffer = "", helper, options;
172
+ buffer += "\n <abbr title=\""
173
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "This field is required", options) : helperMissing.call(depth0, "__", "This field is required", options)))
174
+ + "\">*</abbr>\n ";
175
+ return buffer;
126
176
  }
127
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
128
- this.compilerInfo = [4,'>= 1.0.0'];
129
- helpers = this.merge(helpers, Handlebars.helpers); partials = this.merge(partials, Handlebars.partials); data = data || {};
130
- var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this;
131
-
132
- function program1(depth0,data) {
133
-
134
- var buffer = "", stack1, helper;
135
- buffer += "type=\"";
136
- if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
137
- else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
138
- buffer += escapeExpression(stack1)
139
- + "\" ";
140
- return buffer;
141
- }
142
177
 
143
- buffer += "<div class=\"form-widget ";
144
- if (helper = helpers.widgetType) { stack1 = helper.call(depth0, {hash:{},data:data}); }
145
- else { helper = (depth0 && depth0.widgetType); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
146
- buffer += escapeExpression(stack1)
147
- + "\">\n <div class=\"widget-label\">\n ";
148
- stack1 = self.invokePartial(partials['ui-form-widget-label'], 'ui-form-widget-label', depth0, helpers, partials, data);
149
- if(stack1 || stack1 === 0) { buffer += stack1; }
150
- buffer += "\n </div>\n <div class=\"widget-field\">\n <input class=\"widget-input-inline\" ";
151
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.type), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
152
- if(stack1 || stack1 === 0) { buffer += stack1; }
153
- buffer += "name=\"";
154
- if (helper = helpers.uri) { stack1 = helper.call(depth0, {hash:{},data:data}); }
155
- else { helper = (depth0 && depth0.uri); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
156
- buffer += escapeExpression(stack1)
157
- + "\" value=\"";
158
- if (helper = helpers.value) { stack1 = helper.call(depth0, {hash:{},data:data}); }
159
- else { helper = (depth0 && depth0.value); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
160
- buffer += escapeExpression(stack1)
161
- + "\" />\n </div>\n</div>\n";
162
- return buffer;
163
- });
164
- function widgetTpl(data, options, asString) {
165
- var html = Template(data, options);
166
- return (asString || true) ? html : $(html);
178
+ buffer += "<label for=\"";
179
+ if (helper = helpers.uri) { stack1 = helper.call(depth0, {hash:{},data:data}); }
180
+ else { helper = (depth0 && depth0.uri); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
181
+ buffer += escapeExpression(stack1)
182
+ + "\">\n ";
183
+ if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
184
+ else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
185
+ buffer += escapeExpression(stack1)
186
+ + "\n ";
187
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.required), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
188
+ if(stack1 || stack1 === 0) { buffer += stack1; }
189
+ buffer += "\n</label>\n";
190
+ return buffer;
191
+ });
192
+ function labelTpl(data, options, asString) {
193
+ var html = Template$1(data, options);
194
+ return (asString || true) ? html : $(html);
195
+ }
196
+
197
+ /**
198
+ * This program is free software; you can redistribute it and/or
199
+ * modify it under the terms of the GNU General Public License
200
+ * as published by the Free Software Foundation; under version 2
201
+ * of the License (non-upgradable).
202
+ *
203
+ * This program is distributed in the hope that it will be useful,
204
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
205
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206
+ * GNU General Public License for more details.
207
+ *
208
+ * You should have received a copy of the GNU General Public License
209
+ * along with this program; if not, write to the Free Software
210
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
211
+ *
212
+ * Copyright (c) 2019 Open Assessment Technologies SA ;
213
+ */
214
+ /**
215
+ * @typedef {Object} widgetConfig Defines the config entries available to setup a form widget
216
+ * @property {String} widget - The type of widget.
217
+ * It will be used by the main factory to retrieve
218
+ * the implementation from the internal registry.
219
+ * @property {String} widgetType - The internal type of widget
220
+ * @property {String} uri - The identifier of the widget
221
+ * @property {String} [label] - The label of the widget
222
+ * @property {String|String[]} [value] - The value of the widget. Depending on the widget's type,
223
+ * it can be a single or a multiple value
224
+ * @property {widgetRangeValue[]} [range] - Array of values used in multi-elements widgets (like combo or checkbox)
225
+ * @property {Boolean} [required] - Tells if the value is required
226
+ * @property {validationRule|validationRule[]|validator} [validation] - Optional validators to add
227
+ */
228
+
229
+ /**
230
+ * @typedef {Object} widgetRangeValue Defines a value to use in a widget range
231
+ * @property {String} uri - The identifier of the value
232
+ * @property {String} label - The label for the value
233
+ */
234
+
235
+ /**
236
+ * Some default config
237
+ * @type {widgetConfig}
238
+ */
239
+
240
+ var defaults = {
241
+ widgetType: 'input-box',
242
+ required: false,
243
+ label: __('Label'),
244
+ value: '',
245
+ range: []
246
+ };
247
+ /**
248
+ * Gets the provider with respect to the provided config
249
+ * @param {widgetConfig} config
250
+ * @returns {Object}
251
+ * @throws {TypeError} if the config is not valid or if the provider does not exist
252
+ */
253
+
254
+ function getWidgetProvider(config) {
255
+ if (!_.isPlainObject(config)) {
256
+ throw new TypeError('The config must be an object');
167
257
  }
168
258
 
169
- if (!Helpers0.__initialized) {
170
- Helpers0(Handlebars);
171
- Helpers0.__initialized = true;
259
+ if (!_.isString(config.uri) || !config.uri) {
260
+ throw new TypeError('The config must contain an uri');
172
261
  }
173
- var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
174
- this.compilerInfo = [4,'>= 1.0.0'];
175
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
176
- var buffer = "", stack1, helper, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, functionType="function", self=this;
177
-
178
- function program1(depth0,data) {
179
-
180
- var buffer = "", helper, options;
181
- buffer += "\n <abbr title=\""
182
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "This field is required", options) : helperMissing.call(depth0, "__", "This field is required", options)))
183
- + "\">*</abbr>\n ";
184
- return buffer;
185
- }
186
262
 
187
- buffer += "<label for=\"";
188
- if (helper = helpers.uri) { stack1 = helper.call(depth0, {hash:{},data:data}); }
189
- else { helper = (depth0 && depth0.uri); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
190
- buffer += escapeExpression(stack1)
191
- + "\">\n ";
192
- if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
193
- else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
194
- buffer += escapeExpression(stack1)
195
- + "\n ";
196
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.required), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
197
- if(stack1 || stack1 === 0) { buffer += stack1; }
198
- buffer += "\n</label>\n";
199
- return buffer;
200
- });
201
- function labelTpl(data, options, asString) {
202
- var html = Template$1(data, options);
203
- return (asString || true) ? html : $(html);
263
+ if (!_.isString(config.widget) || !config.widget) {
264
+ throw new TypeError('The config must declare a type of widget');
204
265
  }
205
266
 
206
- /**
207
- * This program is free software; you can redistribute it and/or
208
- * modify it under the terms of the GNU General Public License
209
- * as published by the Free Software Foundation; under version 2
210
- * of the License (non-upgradable).
211
- *
212
- * This program is distributed in the hope that it will be useful,
213
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
214
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
215
- * GNU General Public License for more details.
216
- *
217
- * You should have received a copy of the GNU General Public License
218
- * along with this program; if not, write to the Free Software
219
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
220
- *
221
- * Copyright (c) 2019 Open Assessment Technologies SA ;
222
- */
223
- /**
224
- * @typedef {Object} widgetConfig Defines the config entries available to setup a form widget
225
- * @property {String} widget - The type of widget.
226
- * It will be used by the main factory to retrieve
227
- * the implementation from the internal registry.
228
- * @property {String} widgetType - The internal type of widget
229
- * @property {String} uri - The identifier of the widget
230
- * @property {String} [label] - The label of the widget
231
- * @property {String|String[]} [value] - The value of the widget. Depending on the widget's type,
232
- * it can be a single or a multiple value
233
- * @property {widgetRangeValue[]} [range] - Array of values used in multi-elements widgets (like combo or checkbox)
234
- * @property {Boolean} [required] - Tells if the value is required
235
- * @property {validationRule|validationRule[]|validator} [validation] - Optional validators to add
236
- */
267
+ return widgetFactory.getProvider(config.widget);
268
+ }
269
+ /**
270
+ * Makes sure a value is an array
271
+ * @param {*} value
272
+ * @returns {Array}
273
+ */
237
274
 
238
- /**
239
- * @typedef {Object} widgetRangeValue Defines a value to use in a widget range
240
- * @property {String} uri - The identifier of the value
241
- * @property {String} label - The label for the value
242
- */
243
275
 
276
+ function forceArray(value) {
277
+ if (value && !_.isArray(value)) {
278
+ value = [value];
279
+ } else {
280
+ value = value || [];
281
+ }
282
+
283
+ return value;
284
+ }
285
+ /**
286
+ * Factory that builds a form element based on its config.
287
+ *
288
+ * * @example
289
+ * const container = $('.my-container', $container);
290
+ *
291
+ * widgetFactory.registerProvider('textinput', widgetTextInputProvider);
292
+ *
293
+ * const config = {
294
+ * widget: 'textinput'
295
+ * uri: 'text',
296
+ * label: 'Text',
297
+ * required: true
298
+ * };
299
+ *
300
+ * const widget = widgetFactory(container, config)
301
+ * .on('change', function(value) {
302
+ * // ...
303
+ * });
304
+ *
305
+ * @param {HTMLElement|String} container
306
+ * @param {widgetConfig} config
307
+ * @param {String} config.widget - The type of widget.
308
+ * It will be used by the main factory to retrieve
309
+ * the implementation from the internal registry.
310
+ * @param {String} config.uri - The identifier of the widget
311
+ * @param {String} [config.label] - The label of the widget
312
+ * @param {String|String[]} [config.value] - The value of the widget. Depending on the widget's type,
313
+ * it can be a single or a multiple value
314
+ * @param {widgetRangeValue[]} [config.range] - Array of values used in multi-elements widgets (like combo or checkbox)
315
+ * @param {Boolean} [config.required] - Tells if the value is required
316
+ * @param {validationRule|validationRule[]|validator} [config.validation] - Optional validators to add
317
+ * @returns {widgetForm}
318
+ * @fires ready - When the component is ready to work
319
+ */
320
+
321
+
322
+ function widgetFactory(container, config) {
323
+ var widget;
324
+ var validator;
325
+ var validatorRenderer;
326
+ var provider = getWidgetProvider(config);
244
327
  /**
245
- * Some default config
246
- * @type {widgetConfig}
328
+ * Reflects the invalid state to the component
329
+ * @param {Boolean} invalid
330
+ * @param {String[]} [messages]
247
331
  */
248
332
 
249
- const defaults = {
250
- widgetType: 'input-box',
251
- required: false,
252
- label: __('Label'),
253
- value: '',
254
- range: []
333
+ var setInvalidState = function setInvalidState(invalid, messages) {
334
+ widget.setState('invalid', invalid);
335
+
336
+ if (validatorRenderer) {
337
+ if (invalid) {
338
+ validatorRenderer.display(messages);
339
+ } else {
340
+ validatorRenderer.clear();
341
+ }
342
+ }
255
343
  };
256
344
  /**
257
- * Gets the provider with respect to the provided config
258
- * @param {widgetConfig} config
259
- * @returns {Object}
260
- * @throws {TypeError} if the config is not valid or if the provider does not exist
345
+ * Delegate a call to the provider, or fallback to the default implementation
346
+ * @param {String} method - The name of the method to call.
347
+ * @param {...} args - Extra parameters
348
+ * @returns {*}
261
349
  */
262
350
 
263
- function getWidgetProvider(config) {
264
- if (!_.isPlainObject(config)) {
265
- throw new TypeError('The config must be an object');
266
- }
267
351
 
268
- if (!_.isString(config.uri) || !config.uri) {
269
- throw new TypeError('The config must contain an uri');
352
+ var delegate = function delegate(method) {
353
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
354
+ args[_key - 1] = arguments[_key];
270
355
  }
271
356
 
272
- if (!_.isString(config.widget) || !config.widget) {
273
- throw new TypeError('The config must declare a type of widget');
357
+ if (_.isFunction(provider[method])) {
358
+ return provider[method].apply(widget, args);
274
359
  }
275
360
 
276
- return widgetFactory.getProvider(config.widget);
277
- }
361
+ return defaultProvider[method].apply(widget, args);
362
+ };
278
363
  /**
279
- * Makes sure a value is an array
280
- * @param {*} value
281
- * @returns {Array}
364
+ * Triggers the change event
365
+ * @returns {widgetForm}
366
+ * @fires change
282
367
  */
283
368
 
284
369
 
285
- function forceArray(value) {
286
- if (value && !_.isArray(value)) {
287
- value = [value];
288
- } else {
289
- value = value || [];
290
- }
291
-
292
- return value;
293
- }
370
+ var notifyChange = function notifyChange() {
371
+ /**
372
+ * @event change
373
+ * @param {String|String[]} value
374
+ * @param {String} uri
375
+ */
376
+ widget.trigger('change', widget.getValue(), widget.getUri());
377
+ };
294
378
  /**
295
- * Factory that builds a form element based on its config.
296
- *
297
- * * @example
298
- * const container = $('.my-container', $container);
299
- *
300
- * widgetFactory.registerProvider('textinput', widgetTextInputProvider);
301
- *
302
- * const config = {
303
- * widget: 'textinput'
304
- * uri: 'text',
305
- * label: 'Text',
306
- * required: true
307
- * };
308
- *
309
- * const widget = widgetFactory(container, config)
310
- * .on('change', function(value) {
311
- * // ...
312
- * });
313
- *
314
- * @param {HTMLElement|String} container
315
- * @param {widgetConfig} config
316
- * @param {String} config.widget - The type of widget.
317
- * It will be used by the main factory to retrieve
318
- * the implementation from the internal registry.
319
- * @param {String} config.uri - The identifier of the widget
320
- * @param {String} [config.label] - The label of the widget
321
- * @param {String|String[]} [config.value] - The value of the widget. Depending on the widget's type,
322
- * it can be a single or a multiple value
323
- * @param {widgetRangeValue[]} [config.range] - Array of values used in multi-elements widgets (like combo or checkbox)
324
- * @param {Boolean} [config.required] - Tells if the value is required
325
- * @param {validationRule|validationRule[]|validator} [config.validation] - Optional validators to add
326
- * @returns {widgetForm}
327
- * @fires ready - When the component is ready to work
379
+ * @typedef {component} widgetForm
328
380
  */
329
381
 
330
382
 
331
- function widgetFactory(container, config) {
332
- let widget;
333
- let validator;
334
- let validatorRenderer;
335
- const provider = getWidgetProvider(config);
383
+ var widgetApi = {
336
384
  /**
337
- * Reflects the invalid state to the component
338
- * @param {Boolean} invalid
339
- * @param {String[]} [messages]
385
+ * Gets the widget's URI
386
+ * @returns {String}
340
387
  */
388
+ getUri: function getUri() {
389
+ return this.getConfig().uri;
390
+ },
341
391
 
342
- const setInvalidState = (invalid, messages) => {
343
- widget.setState('invalid', invalid);
392
+ /**
393
+ * Gets the value of the widget
394
+ * @returns {String|String[]}
395
+ */
396
+ getValue: function getValue() {
397
+ return delegate('getValue');
398
+ },
344
399
 
345
- if (validatorRenderer) {
346
- if (invalid) {
347
- validatorRenderer.display(messages);
348
- } else {
349
- validatorRenderer.clear();
350
- }
351
- }
352
- };
353
400
  /**
354
- * Delegate a call to the provider, or fallback to the default implementation
355
- * @param {String} method - The name of the method to call.
356
- * @param {...} args - Extra parameters
401
+ * Gets the raw value of the widget
357
402
  * @returns {*}
358
403
  */
404
+ getRawValue: function getRawValue() {
405
+ return delegate('getRawValue');
406
+ },
359
407
 
360
-
361
- const delegate = function (method) {
362
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
363
- args[_key - 1] = arguments[_key];
364
- }
365
-
366
- if (_.isFunction(provider[method])) {
367
- return provider[method].apply(widget, args);
368
- }
369
-
370
- return defaultProvider[method].apply(widget, args);
371
- };
372
408
  /**
373
- * Triggers the change event
409
+ * Sets the value of the widget
410
+ * @param {String|String[]} value
374
411
  * @returns {widgetForm}
375
- * @fires change
412
+ * @fires change after the value has been changed
376
413
  */
414
+ setValue: function setValue(value) {
415
+ this.getConfig().value = value;
416
+ delegate('setValue', value);
417
+ notifyChange();
418
+ return this;
419
+ },
377
420
 
378
-
379
- const notifyChange = () => {
380
- /**
381
- * @event change
382
- * @param {String|String[]} value
383
- * @param {String} uri
384
- */
385
- widget.trigger('change', widget.getValue(), widget.getUri());
386
- };
387
421
  /**
388
- * @typedef {component} widgetForm
422
+ * Gets access to the validation engine
423
+ * @returns {validator}
389
424
  */
425
+ getValidator: function getValidator() {
426
+ return validator;
427
+ },
390
428
 
391
-
392
- const widgetApi = {
393
- /**
394
- * Gets the widget's URI
395
- * @returns {String}
396
- */
397
- getUri() {
398
- return this.getConfig().uri;
399
- },
400
-
401
- /**
402
- * Gets the value of the widget
403
- * @returns {String|String[]}
404
- */
405
- getValue() {
406
- return delegate('getValue');
407
- },
408
-
409
- /**
410
- * Gets the raw value of the widget
411
- * @returns {*}
412
- */
413
- getRawValue() {
414
- return delegate('getRawValue');
415
- },
416
-
417
- /**
418
- * Sets the value of the widget
419
- * @param {String|String[]} value
420
- * @returns {widgetForm}
421
- * @fires change after the value has been changed
422
- */
423
- setValue(value) {
424
- this.getConfig().value = value;
425
- delegate('setValue', value);
426
- notifyChange();
427
- return this;
428
- },
429
-
430
- /**
431
- * Gets access to the validation engine
432
- * @returns {validator}
433
- */
434
- getValidator() {
435
- return validator;
436
- },
437
-
438
- /**
439
- * Sets the validation engine
440
- * @param {validationRule|validationRule[]|validator} validation
441
- * @returns {widgetForm}
442
- */
443
- setValidator(validation) {
444
- if (validation && _.isFunction(validation.validate)) {
445
- validator = validation;
446
- } else {
447
- if (validation && !validation.validations) {
448
- if (!_.isArray(validation)) {
449
- validation = [validation];
450
- }
451
-
452
- validation = {
453
- validations: validation
454
- };
429
+ /**
430
+ * Sets the validation engine
431
+ * @param {validationRule|validationRule[]|validator} validation
432
+ * @returns {widgetForm}
433
+ */
434
+ setValidator: function setValidator(validation) {
435
+ if (validation && _.isFunction(validation.validate)) {
436
+ validator = validation;
437
+ } else {
438
+ if (validation && !validation.validations) {
439
+ if (!_.isArray(validation)) {
440
+ validation = [validation];
455
441
  }
456
442
 
457
- validator = validatorFactory(validation);
443
+ validation = {
444
+ validations: validation
445
+ };
458
446
  }
459
447
 
460
- return this;
461
- },
462
-
463
- /**
464
- * Resets the widget to the default validators
465
- * @returns {widgetForm}
466
- */
467
- setDefaultValidators() {
468
- // restore factory default validators
469
- this.setValidator(this.getConfig().validator); // then apply provider default validators
470
-
471
- delegate('setDefaultValidators');
472
- return this;
473
- },
474
-
475
- /**
476
- * Resets the widget to its default value
477
- * @returns {widgetForm}
478
- */
479
- reset() {
480
- delegate('reset');
481
- setInvalidState(false);
482
- return this;
483
- },
484
-
485
- /**
486
- * Validates the widget
487
- * @returns {Promise}
488
- */
489
- validate() {
490
- return this.getValidator().validate(this.getRawValue()).then(res => {
491
- setInvalidState(false);
492
- return res;
493
- }).catch(err => {
494
- setInvalidState(true, err);
495
- return Promise.reject(err);
496
- });
497
- },
498
-
499
- /**
500
- * Gets access to the actual form element
501
- * @returns {jQuery|null}
502
- */
503
- getWidgetElement() {
504
- if (this.is('rendered')) {
505
- return delegate('getWidgetElement');
506
- }
507
-
508
- return null;
448
+ validator = validatorFactory(validation);
509
449
  }
510
450
 
511
- };
512
- widget = componentFactory(widgetApi, defaults).setTemplate(provider.template || widgetTpl).on('init', function onWidgetInit() {
513
- this.setDefaultValidators(); // auto render on init (defer the call to give a chance to the init event to be completed before)
451
+ return this;
452
+ },
453
+
454
+ /**
455
+ * Resets the widget to the default validators
456
+ * @returns {widgetForm}
457
+ */
458
+ setDefaultValidators: function setDefaultValidators() {
459
+ // restore factory default validators
460
+ this.setValidator(this.getConfig().validator); // then apply provider default validators
514
461
 
515
- _.defer(() => this.render(container));
516
- }).on('render', function onWidgetRender() {
517
- // reflect the type of widget
518
- this.setState(this.getConfig().widgetType, true); // react to data change
462
+ delegate('setDefaultValidators');
463
+ return this;
464
+ },
519
465
 
520
- this.getWidgetElement().on('change blur', () => {
521
- const value = this.getValue();
466
+ /**
467
+ * Resets the widget to its default value
468
+ * @returns {widgetForm}
469
+ */
470
+ reset: function reset() {
471
+ delegate('reset');
472
+ setInvalidState(false);
473
+ return this;
474
+ },
522
475
 
523
- if (value !== this.getConfig().value) {
524
- this.getConfig().value = value;
525
- notifyChange();
526
- }
476
+ /**
477
+ * Validates the widget
478
+ * @returns {Promise}
479
+ */
480
+ validate: function validate() {
481
+ return this.getValidator().validate(this.getRawValue()).then(function (res) {
482
+ setInvalidState(false);
483
+ return res;
484
+ }).catch(function (err) {
485
+ setInvalidState(true, err);
486
+ return Promise.reject(err);
527
487
  });
528
- /**
529
- * @event ready
530
- */
488
+ },
531
489
 
532
- validatorRenderer = validatorRendererFactory(this.getElement()).spread(this, 'error ready');
533
- }).on('disable', function onWidgetDisable() {
534
- if (this.is('rendered')) {
535
- this.getWidgetElement().prop('disabled', true);
536
- }
537
- }).on('enable', function onWidgetEnable() {
490
+ /**
491
+ * Gets access to the actual form element
492
+ * @returns {jQuery|null}
493
+ */
494
+ getWidgetElement: function getWidgetElement() {
538
495
  if (this.is('rendered')) {
539
- this.getWidgetElement().prop('disabled', false);
496
+ return delegate('getWidgetElement');
540
497
  }
541
- }).on('destroy', function onWidgetDestroy() {
542
- if (validatorRenderer) {
543
- validatorRenderer.destroy();
544
- validatorRenderer = null;
498
+
499
+ return null;
500
+ }
501
+ };
502
+ widget = componentFactory(widgetApi, defaults).setTemplate(provider.template || widgetTpl).on('init', function onWidgetInit() {
503
+ var _this = this;
504
+
505
+ this.setDefaultValidators(); // auto render on init (defer the call to give a chance to the init event to be completed before)
506
+
507
+ _.defer(function () {
508
+ return _this.render(container);
509
+ });
510
+ }).on('render', function onWidgetRender() {
511
+ var _this2 = this;
512
+
513
+ // reflect the type of widget
514
+ this.setState(this.getConfig().widgetType, true); // react to data change
515
+
516
+ this.getWidgetElement().on('change blur', function () {
517
+ var value = _this2.getValue();
518
+
519
+ if (value !== _this2.getConfig().value) {
520
+ _this2.getConfig().value = value;
521
+ notifyChange();
545
522
  }
546
523
  });
524
+ /**
525
+ * @event ready
526
+ */
547
527
 
548
- if (config) {
549
- // the range must be an array
550
- config.range = forceArray(config.range);
528
+ validatorRenderer = validatorRendererFactory(this.getElement()).spread(this, 'error ready');
529
+ }).on('disable', function onWidgetDisable() {
530
+ if (this.is('rendered')) {
531
+ this.getWidgetElement().prop('disabled', true);
532
+ }
533
+ }).on('enable', function onWidgetEnable() {
534
+ if (this.is('rendered')) {
535
+ this.getWidgetElement().prop('disabled', false);
551
536
  }
537
+ }).on('destroy', function onWidgetDestroy() {
538
+ if (validatorRenderer) {
539
+ validatorRenderer.destroy();
540
+ validatorRenderer = null;
541
+ }
542
+ });
543
+
544
+ if (config) {
545
+ // the range must be an array
546
+ config.range = forceArray(config.range);
547
+ }
552
548
 
553
- _.defer(() => widget.init(provider.init.call(widget, config || {}) || config));
549
+ _.defer(function () {
550
+ return widget.init(provider.init.call(widget, config || {}) || config);
551
+ });
554
552
 
555
- return widget;
556
- } // expose a partial that can be used by every form widget to inject the label markup
553
+ return widget;
554
+ } // expose a partial that can be used by every form widget to inject the label markup
557
555
 
558
556
 
559
- Handlebars.registerPartial('ui-form-widget-label', labelTpl); // the widgetFactory is also a providers registry
557
+ Handlebars.registerPartial('ui-form-widget-label', labelTpl); // the widgetFactory is also a providers registry
560
558
 
561
- providerRegistry(widgetFactory);
559
+ providerRegistry(widgetFactory);
562
560
 
563
- return widgetFactory;
561
+ return widgetFactory;
564
562
 
565
563
  });