@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
package/dist/dialog.js CHANGED
@@ -1,758 +1,754 @@
1
1
  define(['jquery', 'lodash', 'i18n', 'handlebars', 'lib/dompurify/purify', 'ui/keyNavigation/navigator', 'ui/keyNavigation/navigableDomElement', 'util/shortcut/registry', 'ui/modal'], function ($$1, _, __, Handlebars, DOMPurify, keyNavigator, navigableDomElement, shortcutRegistry, modal) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
6
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
8
- keyNavigator = keyNavigator && Object.prototype.hasOwnProperty.call(keyNavigator, 'default') ? keyNavigator['default'] : keyNavigator;
9
- navigableDomElement = navigableDomElement && Object.prototype.hasOwnProperty.call(navigableDomElement, 'default') ? navigableDomElement['default'] : navigableDomElement;
10
- shortcutRegistry = shortcutRegistry && Object.prototype.hasOwnProperty.call(shortcutRegistry, 'default') ? shortcutRegistry['default'] : shortcutRegistry;
11
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
6
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
8
+ keyNavigator = keyNavigator && Object.prototype.hasOwnProperty.call(keyNavigator, 'default') ? keyNavigator['default'] : keyNavigator;
9
+ navigableDomElement = navigableDomElement && Object.prototype.hasOwnProperty.call(navigableDomElement, 'default') ? navigableDomElement['default'] : navigableDomElement;
10
+ shortcutRegistry = shortcutRegistry && Object.prototype.hasOwnProperty.call(shortcutRegistry, 'default') ? shortcutRegistry['default'] : shortcutRegistry;
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
+ * Register dompurify helper
28
29
  *
30
+ * https://github.com/cure53/DOMPurify
31
+ * with config SAFE_FOR_TEMPLATES: true
32
+ * to make output safe for template systems
33
+ */
34
+
35
+ hb.registerHelper('dompurify', function (context) {
36
+ return DOMPurify.sanitize(context);
37
+ });
38
+ /**
39
+ * Register join helper
29
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*
30
45
  */
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
46
 
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
- */
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 : '"';
55
52
 
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 : '"';
61
-
62
- _.forIn(arr, function (value, key) {
63
- var fragment = '';
64
-
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, self=this;
130
-
131
- function program1(depth0,data) {
132
-
133
- var buffer = "", stack1, helper;
134
- buffer += "\n aria-labelledby=\"core/ui-dialog-heading-";
135
- if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
136
- else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
137
- buffer += escapeExpression(stack1)
138
- + "\"\n ";
139
- return buffer;
84
+ for (var i = startIndex; i < stopIndex; i += increment) {
85
+ ret += options.fn(_.extend({}, this, {
86
+ i: i
87
+ }));
140
88
  }
141
89
 
142
- function program3(depth0,data) {
143
-
144
- var buffer = "", stack1, helper;
145
- buffer += "\n <h4 id=\"core/ui-dialog-heading-";
146
- if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
147
- else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
148
- buffer += escapeExpression(stack1)
149
- + "\" class=\"strong\">";
150
- if (helper = helpers.heading) { stack1 = helper.call(depth0, {hash:{},data:data}); }
151
- else { helper = (depth0 && depth0.heading); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
152
- buffer += escapeExpression(stack1)
153
- + "</h4>\n ";
154
- 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);
155
97
  }
98
+ }); // register a "get property" helper
99
+ // it gets the named property from the provided context
100
+
101
+ hb.registerHelper('property', function (name, context) {
102
+ return context[name] || '';
103
+ }); // register an 'includes' helper
104
+ // it checks if value is in array
156
105
 
157
- function program5(depth0,data) {
158
-
159
- var buffer = "", stack1, helper;
160
- buffer += "\n <div class=\"content\">";
161
- if (helper = helpers.content) { stack1 = helper.call(depth0, {hash:{},data:data}); }
162
- else { helper = (depth0 && depth0.content); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
163
- if(stack1 || stack1 === 0) { buffer += stack1; }
164
- buffer += "</div>\n ";
165
- return buffer;
106
+ hb.registerHelper('includes', function (haystack, needle, options) {
107
+ if (_.contains(haystack, needle)) {
108
+ return options.fn(this);
166
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, self=this;
121
+
122
+ function program1(depth0,data) {
123
+
124
+ var buffer = "", stack1, helper;
125
+ buffer += "\n aria-labelledby=\"core/ui-dialog-heading-";
126
+ if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
127
+ else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
128
+ buffer += escapeExpression(stack1)
129
+ + "\"\n ";
130
+ return buffer;
131
+ }
167
132
 
168
- buffer += "<div\n class=\"preview-modal-feedback modal ";
169
- if (helper = helpers['class']) { stack1 = helper.call(depth0, {hash:{},data:data}); }
170
- else { helper = (depth0 && depth0['class']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
171
- buffer += escapeExpression(stack1)
172
- + "\"\n role=\"dialog\"\n aria-modal=\"true\"\n data-control=\"navigable-modal-body\"\n ";
173
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.heading), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
174
- if(stack1 || stack1 === 0) { buffer += stack1; }
175
- buffer += "\n aria-describedby=\"core/ui-dialog-message-";
176
- if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
177
- else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
178
- buffer += escapeExpression(stack1)
179
- + "\"\n>\n <div class=\"modal-body clearfix\">\n ";
180
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.heading), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
181
- if(stack1 || stack1 === 0) { buffer += stack1; }
182
- buffer += "\n\n <p id=\"core/ui-dialog-message-";
183
- if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
184
- else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
185
- buffer += escapeExpression(stack1)
186
- + "\" class=\"message\">";
187
- if (helper = helpers.message) { stack1 = helper.call(depth0, {hash:{},data:data}); }
188
- else { helper = (depth0 && depth0.message); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
189
- if(stack1 || stack1 === 0) { buffer += stack1; }
190
- buffer += "</p>\n\n ";
191
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.content), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
192
- if(stack1 || stack1 === 0) { buffer += stack1; }
193
- buffer += "\n\n <div class=\"buttons rgt\"></div>\n </div>\n</div>\n";
194
- return buffer;
195
- });
196
- function bodyTpl(data, options, asString) {
197
- var html = Template(data, options);
198
- return (asString || true) ? html : $(html);
133
+ function program3(depth0,data) {
134
+
135
+ var buffer = "", stack1, helper;
136
+ buffer += "\n <h4 id=\"core/ui-dialog-heading-";
137
+ if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
138
+ else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
139
+ buffer += escapeExpression(stack1)
140
+ + "\" class=\"strong\">";
141
+ if (helper = helpers.heading) { stack1 = helper.call(depth0, {hash:{},data:data}); }
142
+ else { helper = (depth0 && depth0.heading); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
143
+ buffer += escapeExpression(stack1)
144
+ + "</h4>\n ";
145
+ return buffer;
199
146
  }
200
147
 
201
- if (!Helpers0.__initialized) {
202
- Helpers0(Handlebars);
203
- Helpers0.__initialized = true;
148
+ function program5(depth0,data) {
149
+
150
+ var buffer = "", stack1, helper;
151
+ buffer += "\n <div class=\"content\">";
152
+ if (helper = helpers.content) { stack1 = helper.call(depth0, {hash:{},data:data}); }
153
+ else { helper = (depth0 && depth0.content); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
154
+ if(stack1 || stack1 === 0) { buffer += stack1; }
155
+ buffer += "</div>\n ";
156
+ return buffer;
204
157
  }
205
- var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
206
- this.compilerInfo = [4,'>= 1.0.0'];
207
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
208
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
209
-
210
- function program1(depth0,data) {
211
-
212
- var buffer = "", stack1, helper;
213
- buffer += "\n <button class=\"btn-";
214
- if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
215
- else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
216
- buffer += escapeExpression(stack1)
217
- + " small ";
218
- if (helper = helpers.id) { stack1 = helper.call(depth0, {hash:{},data:data}); }
219
- else { helper = (depth0 && depth0.id); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
220
- buffer += escapeExpression(stack1)
221
- + "\" data-control=\"";
222
- if (helper = helpers.id) { stack1 = helper.call(depth0, {hash:{},data:data}); }
223
- else { helper = (depth0 && depth0.id); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
224
- buffer += escapeExpression(stack1)
225
- + "\" type=\"button\">\n ";
226
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.icon), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
227
- if(stack1 || stack1 === 0) { buffer += stack1; }
228
- buffer += "\n <span class=\"label\">";
229
- if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
230
- else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
231
- buffer += escapeExpression(stack1)
232
- + "</span>\n </button>\n";
233
- return buffer;
234
- }
235
- function program2(depth0,data) {
236
-
237
- var buffer = "", stack1, helper;
238
- buffer += "<span class=\"icon-";
239
- if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
240
- else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
241
- buffer += escapeExpression(stack1)
242
- + "\"></span> ";
243
- return buffer;
244
- }
245
158
 
246
- stack1 = helpers.each.call(depth0, (depth0 && depth0.buttons), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
247
- if(stack1 || stack1 === 0) { buffer += stack1; }
248
- buffer += "\n";
249
- return buffer;
250
- });
251
- function buttonsTpl(data, options, asString) {
252
- var html = Template$1(data, options);
253
- return (asString || true) ? html : $(html);
159
+ buffer += "<div\n class=\"preview-modal-feedback modal ";
160
+ if (helper = helpers['class']) { stack1 = helper.call(depth0, {hash:{},data:data}); }
161
+ else { helper = (depth0 && depth0['class']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
162
+ buffer += escapeExpression(stack1)
163
+ + "\"\n role=\"dialog\"\n aria-modal=\"true\"\n data-control=\"navigable-modal-body\"\n ";
164
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.heading), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
165
+ if(stack1 || stack1 === 0) { buffer += stack1; }
166
+ buffer += "\n aria-describedby=\"core/ui-dialog-message-";
167
+ if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
168
+ else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
169
+ buffer += escapeExpression(stack1)
170
+ + "\"\n>\n <div class=\"modal-body clearfix\">\n ";
171
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.heading), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
172
+ if(stack1 || stack1 === 0) { buffer += stack1; }
173
+ buffer += "\n\n <p id=\"core/ui-dialog-message-";
174
+ if (helper = helpers.dialogId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
175
+ else { helper = (depth0 && depth0.dialogId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
176
+ buffer += escapeExpression(stack1)
177
+ + "\" class=\"message\">";
178
+ if (helper = helpers.message) { stack1 = helper.call(depth0, {hash:{},data:data}); }
179
+ else { helper = (depth0 && depth0.message); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
180
+ if(stack1 || stack1 === 0) { buffer += stack1; }
181
+ buffer += "</p>\n\n ";
182
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.content), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
183
+ if(stack1 || stack1 === 0) { buffer += stack1; }
184
+ buffer += "\n\n <div class=\"buttons rgt\"></div>\n </div>\n</div>\n";
185
+ return buffer;
186
+ });
187
+ function bodyTpl(data, options, asString) {
188
+ var html = Template(data, options);
189
+ return (asString || true) ? html : $(html);
190
+ }
191
+
192
+ if (!Helpers0.__initialized) {
193
+ Helpers0(Handlebars);
194
+ Helpers0.__initialized = true;
195
+ }
196
+ var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
197
+ this.compilerInfo = [4,'>= 1.0.0'];
198
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
199
+ var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
200
+
201
+ function program1(depth0,data) {
202
+
203
+ var buffer = "", stack1, helper;
204
+ buffer += "\n <button class=\"btn-";
205
+ if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
206
+ else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
207
+ buffer += escapeExpression(stack1)
208
+ + " small ";
209
+ if (helper = helpers.id) { stack1 = helper.call(depth0, {hash:{},data:data}); }
210
+ else { helper = (depth0 && depth0.id); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
211
+ buffer += escapeExpression(stack1)
212
+ + "\" data-control=\"";
213
+ if (helper = helpers.id) { stack1 = helper.call(depth0, {hash:{},data:data}); }
214
+ else { helper = (depth0 && depth0.id); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
215
+ buffer += escapeExpression(stack1)
216
+ + "\" type=\"button\">\n ";
217
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.icon), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
218
+ if(stack1 || stack1 === 0) { buffer += stack1; }
219
+ buffer += "\n <span class=\"label\">";
220
+ if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
221
+ else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
222
+ buffer += escapeExpression(stack1)
223
+ + "</span>\n </button>\n";
224
+ return buffer;
225
+ }
226
+ function program2(depth0,data) {
227
+
228
+ var buffer = "", stack1, helper;
229
+ buffer += "<span class=\"icon-";
230
+ if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
231
+ else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
232
+ buffer += escapeExpression(stack1)
233
+ + "\"></span> ";
234
+ return buffer;
254
235
  }
255
236
 
237
+ stack1 = helpers.each.call(depth0, (depth0 && depth0.buttons), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
238
+ if(stack1 || stack1 === 0) { buffer += stack1; }
239
+ buffer += "\n";
240
+ return buffer;
241
+ });
242
+ function buttonsTpl(data, options, asString) {
243
+ var html = Template$1(data, options);
244
+ return (asString || true) ? html : $(html);
245
+ }
246
+
247
+ /**
248
+ * This program is free software; you can redistribute it and/or
249
+ * modify it under the terms of the GNU General Public License
250
+ * as published by the Free Software Foundation; under version 2
251
+ * of the License (non-upgradable).
252
+ *
253
+ * This program is distributed in the hope that it will be useful,
254
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
255
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
256
+ * GNU General Public License for more details.
257
+ *
258
+ * You should have received a copy of the GNU General Public License
259
+ * along with this program; if not, write to the Free Software
260
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
261
+ *
262
+ * Copyright (c) 2015-2019 (original work) Open Assessment Technologies SA ;
263
+ */
264
+ /**
265
+ * The scope of events names
266
+ * @type {string}
267
+ */
268
+
269
+ var _scope = '.modal';
270
+ /**
271
+ * A list of predefined buttons
272
+ * @type {Object}
273
+ */
274
+
275
+ var _definedButtons = {
276
+ ok: {
277
+ id: 'ok',
278
+ type: 'info',
279
+ label: __('Ok'),
280
+ close: true
281
+ },
282
+ cancel: {
283
+ id: 'cancel',
284
+ type: 'regular',
285
+ label: __('Cancel'),
286
+ close: true
287
+ },
288
+ yes: {
289
+ id: 'yes',
290
+ type: 'info',
291
+ label: __('Yes'),
292
+ close: true
293
+ },
294
+ no: {
295
+ id: 'no',
296
+ type: 'regular',
297
+ label: __('No'),
298
+ close: true
299
+ }
300
+ };
301
+ /**
302
+ * The defaults fields values
303
+ * @type {Object}
304
+ */
305
+
306
+ var _defaults = {
307
+ message: '',
308
+ content: '',
309
+ width: 500,
310
+ animate: false,
311
+ autoRender: false,
312
+ autoDestroy: false,
313
+ renderTo: 'body',
314
+ buttons: 'cancel,ok'
315
+ };
316
+ /**
317
+ * Define a dialog box
318
+ * @type {Object}
319
+ */
320
+
321
+ var dialog = {
256
322
  /**
257
- * This program is free software; you can redistribute it and/or
258
- * modify it under the terms of the GNU General Public License
259
- * as published by the Free Software Foundation; under version 2
260
- * of the License (non-upgradable).
261
- *
262
- * This program is distributed in the hope that it will be useful,
263
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
264
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
265
- * GNU General Public License for more details.
266
- *
267
- * You should have received a copy of the GNU General Public License
268
- * along with this program; if not, write to the Free Software
269
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
270
- *
271
- * Copyright (c) 2015-2019 (original work) Open Assessment Technologies SA ;
272
- */
273
- /**
274
- * The scope of events names
275
- * @type {string}
323
+ * Initialise the dialog box.
324
+ * @param {Object} options - A list of options.
325
+ * @param {String} options.heading - An optional heading to display.
326
+ * @param {String} options.message - The message to display.
327
+ * @param {String} options.content - An optional content to display under the displayed message.
328
+ * @param {String} options.class - Space-separated string of classes to add to the root HTML element
329
+ * @param {Array|Object|String} options.buttons - A list of buttons to display (default: 'cancel,ok'). Can be:
330
+ * - a string: the button names separated by commas
331
+ * - an array: an array of button names or an array of button definitions
332
+ * - an object: a unique button definition, containing:
333
+ * - id: The button's id
334
+ * - type: A display type (regular, info, warning, error)
335
+ * - label: The button's caption
336
+ * - icon: An optional icon
337
+ * - close: A boolean value telling if the dialog must be closed after the button has been activated
338
+ * @param {String|jQuery|HTMLElement} options.renderTo - A container in which renders the dialog (default: 'body').
339
+ * @param {Boolean} options.autoRender - Allow the dialog to be immediately rendered after initialise.
340
+ * @param {Boolean} options.autoDestroy - Allow the dialog to be immediately destroyed when closing.
341
+ * @param {Boolean} [options.disableClosing = false] - to disable the default closers
342
+ * @param {Boolean} [options.disableEscape = false] - to disable the ability to escape close the dialog
343
+ * @param {Number} options.width - The dialog box width in pixels (default: 500).
344
+ * @param {Number|Boolean} options.animate - The dialog box animate duration (default: false).
345
+ * @param {Function} options.onXYZbtn - An event handler assigned to a particular button (XYZ).
346
+ * @returns {dialog}
276
347
  */
348
+ init: function init(options) {
349
+ var _this = this;
277
350
 
278
- const _scope = '.modal';
279
- /**
280
- * A list of predefined buttons
281
- * @type {Object}
282
- */
351
+ // split options to events
352
+ var events = {};
283
353
 
284
- const _definedButtons = {
285
- ok: {
286
- id: 'ok',
287
- type: 'info',
288
- label: __('Ok'),
289
- close: true
290
- },
291
- cancel: {
292
- id: 'cancel',
293
- type: 'regular',
294
- label: __('Cancel'),
295
- close: true
296
- },
297
- yes: {
298
- id: 'yes',
299
- type: 'info',
300
- label: __('Yes'),
301
- close: true
302
- },
303
- no: {
304
- id: 'no',
305
- type: 'regular',
306
- label: __('No'),
307
- close: true
308
- }
309
- };
310
- /**
311
- * The defaults fields values
312
- * @type {Object}
313
- */
354
+ var initOptions = _.omit(options || {}, function (value, key) {
355
+ if (key.length > 2 && 'on' === key.substr(0, 2)) {
356
+ events[key.substr(2)] = value;
357
+ return true;
358
+ }
314
359
 
315
- const _defaults = {
316
- message: '',
317
- content: '',
318
- width: 500,
319
- animate: false,
320
- autoRender: false,
321
- autoDestroy: false,
322
- renderTo: 'body',
323
- buttons: 'cancel,ok'
324
- };
325
- /**
326
- * Define a dialog box
327
- * @type {Object}
328
- */
360
+ return false;
361
+ }); // assign default values and options
329
362
 
330
- const dialog = {
331
- /**
332
- * Initialise the dialog box.
333
- * @param {Object} options - A list of options.
334
- * @param {String} options.heading - An optional heading to display.
335
- * @param {String} options.message - The message to display.
336
- * @param {String} options.content - An optional content to display under the displayed message.
337
- * @param {String} options.class - Space-separated string of classes to add to the root HTML element
338
- * @param {Array|Object|String} options.buttons - A list of buttons to display (default: 'cancel,ok'). Can be:
339
- * - a string: the button names separated by commas
340
- * - an array: an array of button names or an array of button definitions
341
- * - an object: a unique button definition, containing:
342
- * - id: The button's id
343
- * - type: A display type (regular, info, warning, error)
344
- * - label: The button's caption
345
- * - icon: An optional icon
346
- * - close: A boolean value telling if the dialog must be closed after the button has been activated
347
- * @param {String|jQuery|HTMLElement} options.renderTo - A container in which renders the dialog (default: 'body').
348
- * @param {Boolean} options.autoRender - Allow the dialog to be immediately rendered after initialise.
349
- * @param {Boolean} options.autoDestroy - Allow the dialog to be immediately destroyed when closing.
350
- * @param {Boolean} [options.disableClosing = false] - to disable the default closers
351
- * @param {Boolean} [options.disableEscape = false] - to disable the ability to escape close the dialog
352
- * @param {Number} options.width - The dialog box width in pixels (default: 500).
353
- * @param {Number|Boolean} options.animate - The dialog box animate duration (default: false).
354
- * @param {Function} options.onXYZbtn - An event handler assigned to a particular button (XYZ).
355
- * @returns {dialog}
356
- */
357
- init(options) {
358
- // split options to events
359
- const events = {};
360
-
361
- const initOptions = _.omit(options || {}, (value, key) => {
362
- if (key.length > 2 && 'on' === key.substr(0, 2)) {
363
- events[key.substr(2)] = value;
364
- return true;
365
- }
366
363
 
367
- return false;
368
- }); // assign default values and options
364
+ _.defaults(this, initOptions, _defaults); // pre-render the dialog box
369
365
 
370
366
 
371
- _.defaults(this, initOptions, _defaults); // pre-render the dialog box
367
+ this.dialogId = _.uniqueId('dlg-');
368
+ this.$html = $$1(bodyTpl(this));
369
+ this.$buttons = this.$html.find('.buttons');
370
+ this.rendered = false;
371
+ this.destroyed = false; // install the buttons and bind the actions
372
372
 
373
+ this.$buttons.on('click' + _scope, 'button', this._onButtonClick.bind(this));
374
+ this.setButtons(this.buttons); // install the events extracted from the options
373
375
 
374
- this.dialogId = _.uniqueId('dlg-');
375
- this.$html = $$1(bodyTpl(this));
376
- this.$buttons = this.$html.find('.buttons');
377
- this.rendered = false;
378
- this.destroyed = false; // install the buttons and bind the actions
376
+ _.forEach(events, function (callback, eventName) {
377
+ if (eventName.indexOf('.') < 0) {
378
+ eventName += _scope;
379
+ }
379
380
 
380
- this.$buttons.on('click' + _scope, 'button', this._onButtonClick.bind(this));
381
- this.setButtons(this.buttons); // install the events extracted from the options
381
+ _this.on(eventName.toLowerCase(), callback);
382
+ });
382
383
 
383
- _.forEach(events, (callback, eventName) => {
384
- if (eventName.indexOf('.') < 0) {
385
- eventName += _scope;
386
- }
384
+ if (this.autoRender) {
385
+ this.render();
386
+ }
387
387
 
388
- this.on(eventName.toLowerCase(), callback);
389
- });
388
+ return this;
389
+ },
390
390
 
391
- if (this.autoRender) {
392
- this.render();
393
- }
391
+ /**
392
+ * Destroys the dialog box
393
+ * @returns {dialog}
394
+ * @fires dialog#destroy.modal
395
+ */
396
+ destroy: function destroy() {
397
+ if (!this.destroyed) {
398
+ this._destroy(); // reset the context
394
399
 
395
- return this;
396
- },
397
400
 
398
- /**
399
- * Destroys the dialog box
400
- * @returns {dialog}
401
- * @fires dialog#destroy.modal
402
- */
403
- destroy() {
404
- if (!this.destroyed) {
405
- this._destroy(); // reset the context
401
+ this.rendered = false;
402
+ this.destroyed = true;
403
+ this.trigger('destroy' + _scope); // disable events and remove DOM
404
+
405
+ this.$buttons.off(_scope);
406
+ this.$html.off(_scope).remove();
407
+ this.$html = null;
408
+ this.$buttons = null;
409
+ }
406
410
 
411
+ return this;
412
+ },
407
413
 
408
- this.rendered = false;
409
- this.destroyed = true;
410
- this.trigger('destroy' + _scope); // disable events and remove DOM
414
+ /**
415
+ * Set the action buttons
416
+ * @param {Object|Array|String} buttons
417
+ * @returns {dialog}
418
+ */
419
+ setButtons: function setButtons(buttons) {
420
+ var _this2 = this;
411
421
 
412
- this.$buttons.off(_scope);
413
- this.$html.off(_scope).remove();
414
- this.$html = null;
415
- this.$buttons = null;
422
+ if (!this.destroyed) {
423
+ if (!buttons) {
424
+ buttons = _defaults.buttons;
416
425
  }
417
426
 
418
- return this;
419
- },
420
-
421
- /**
422
- * Set the action buttons
423
- * @param {Object|Array|String} buttons
424
- * @returns {dialog}
425
- */
426
- setButtons(buttons) {
427
- if (!this.destroyed) {
428
- if (!buttons) {
429
- buttons = _defaults.buttons;
427
+ if (!_.isArray(buttons)) {
428
+ // buttons can be set as a list of names
429
+ if (_.isString(buttons)) {
430
+ buttons = buttons.split(',');
430
431
  }
431
-
432
- if (!_.isArray(buttons)) {
433
- // buttons can be set as a list of names
434
- if (_.isString(buttons)) {
435
- buttons = buttons.split(',');
436
- }
437
- } // bind the buttons with
432
+ } // bind the buttons with
438
433
 
439
434
 
440
- this.buttons = {};
435
+ this.buttons = {};
441
436
 
442
- _.forEach(buttons, btn => {
443
- if (_.isString(btn)) {
444
- btn = btn.trim();
445
- btn = _definedButtons[btn] || {
446
- id: btn,
447
- type: 'info',
448
- label: btn
449
- };
450
- }
437
+ _.forEach(buttons, function (btn) {
438
+ if (_.isString(btn)) {
439
+ btn = btn.trim();
440
+ btn = _definedButtons[btn] || {
441
+ id: btn,
442
+ type: 'info',
443
+ label: btn
444
+ };
445
+ }
451
446
 
452
- if (!btn.type) {
453
- btn.type = 'regular';
454
- }
447
+ if (!btn.type) {
448
+ btn.type = 'regular';
449
+ }
455
450
 
456
- this.buttons[btn.id] = btn;
457
- });
451
+ _this2.buttons[btn.id] = btn;
452
+ });
458
453
 
459
- this.$buttons.html(buttonsTpl(this));
460
- }
454
+ this.$buttons.html(buttonsTpl(this));
455
+ }
461
456
 
462
- return this;
463
- },
457
+ return this;
458
+ },
464
459
 
465
- /**
466
- * Renders and shows the dialog box
467
- * @param {String|HTMLElement|jQuery} [to]
468
- * @returns {dialog}
469
- * @fires modal#create.modal
470
- */
471
- render(to) {
472
- if (!this.destroyed) {
473
- $$1(to || this.renderTo).append(this.$html);
460
+ /**
461
+ * Renders and shows the dialog box
462
+ * @param {String|HTMLElement|jQuery} [to]
463
+ * @returns {dialog}
464
+ * @fires modal#create.modal
465
+ */
466
+ render: function render(to) {
467
+ if (!this.destroyed) {
468
+ $$1(to || this.renderTo).append(this.$html);
474
469
 
475
- this._install();
470
+ this._install();
476
471
 
477
- this.rendered = true;
478
- }
472
+ this.rendered = true;
473
+ }
479
474
 
480
- return this;
481
- },
475
+ return this;
476
+ },
482
477
 
483
- /**
484
- * Shows the dialog box. Also renders if needed.
485
- * @returns {dialog}
486
- * @fires modal#opened.modal
487
- */
488
- show() {
489
- if (!this.destroyed) {
490
- if (!this.rendered) {
491
- this.render();
492
- } else {
493
- this._open();
494
- }
478
+ /**
479
+ * Shows the dialog box. Also renders if needed.
480
+ * @returns {dialog}
481
+ * @fires modal#opened.modal
482
+ */
483
+ show: function show() {
484
+ if (!this.destroyed) {
485
+ if (!this.rendered) {
486
+ this.render();
487
+ } else {
488
+ this._open();
495
489
  }
490
+ }
496
491
 
497
- return this;
498
- },
492
+ return this;
493
+ },
499
494
 
500
- /**
501
- * Hides the dialog box. Does nothing if the dialog box has not been rendered.
502
- * @returns {dialog}
503
- * @fires modal#closed.modal
504
- */
505
- hide() {
506
- if (!this.destroyed && this.rendered) {
507
- this._close();
495
+ /**
496
+ * Hides the dialog box. Does nothing if the dialog box has not been rendered.
497
+ * @returns {dialog}
498
+ * @fires modal#closed.modal
499
+ */
500
+ hide: function hide() {
501
+ if (!this.destroyed && this.rendered) {
502
+ this._close();
508
503
 
509
- if (this.autoDestroy) {
510
- this.destroy();
511
- }
504
+ if (this.autoDestroy) {
505
+ this.destroy();
512
506
  }
507
+ }
513
508
 
514
- return this;
515
- },
516
-
517
- /**
518
- * Install an event handler on the underlying DOM element
519
- * @param {String} eventName
520
- * @returns {dialog}
521
- */
522
- on(eventName) {
523
- if (this.$html) {
524
- this.$html.on.apply(this.$html, arguments);
525
- }
509
+ return this;
510
+ },
526
511
 
527
- return this;
528
- },
512
+ /**
513
+ * Install an event handler on the underlying DOM element
514
+ * @param {String} eventName
515
+ * @returns {dialog}
516
+ */
517
+ on: function on(eventName) {
518
+ if (this.$html) {
519
+ this.$html.on.apply(this.$html, arguments);
520
+ }
529
521
 
530
- /**
531
- * Uninstall an event handler from the underlying DOM element
532
- * @param {String} eventName
533
- * @returns {dialog}
534
- */
535
- off(eventName) {
536
- if (this.$html) {
537
- this.$html.off.apply(this.$html, arguments);
538
- }
522
+ return this;
523
+ },
539
524
 
540
- return this;
541
- },
525
+ /**
526
+ * Uninstall an event handler from the underlying DOM element
527
+ * @param {String} eventName
528
+ * @returns {dialog}
529
+ */
530
+ off: function off(eventName) {
531
+ if (this.$html) {
532
+ this.$html.off.apply(this.$html, arguments);
533
+ }
542
534
 
543
- /**
544
- * Triggers an event on the underlying DOM element
545
- * @param {String} eventName
546
- * @param {Array|Object} extraParameters
547
- * @returns {dialog}
548
- */
549
- trigger(eventName, extraParameters) {
550
- if (this.$html) {
551
- if (undefined === extraParameters) {
552
- extraParameters = [];
553
- }
535
+ return this;
536
+ },
554
537
 
555
- if (!_.isArray(extraParameters)) {
556
- extraParameters = [extraParameters];
557
- }
538
+ /**
539
+ * Triggers an event on the underlying DOM element
540
+ * @param {String} eventName
541
+ * @param {Array|Object} extraParameters
542
+ * @returns {dialog}
543
+ */
544
+ trigger: function trigger(eventName, extraParameters) {
545
+ if (this.$html) {
546
+ if (undefined === extraParameters) {
547
+ extraParameters = [];
548
+ }
558
549
 
559
- extraParameters = Array.prototype.slice.call(extraParameters);
560
- extraParameters.push(this);
561
- this.$html.trigger(eventName, extraParameters);
550
+ if (!_.isArray(extraParameters)) {
551
+ extraParameters = [extraParameters];
562
552
  }
563
553
 
564
- return this;
565
- },
554
+ extraParameters = Array.prototype.slice.call(extraParameters);
555
+ extraParameters.push(this);
556
+ this.$html.trigger(eventName, extraParameters);
557
+ }
566
558
 
567
- /**
568
- * Gets the underlying DOM element
569
- * @returns {jQuery}
570
- */
571
- getDom() {
572
- return this.$html;
573
- },
559
+ return this;
560
+ },
574
561
 
575
- /**
576
- * Called when button is clicked.
577
- * Executes a button related action
578
- * @param {Event} event
579
- * @private
580
- */
581
- _onButtonClick(event) {
582
- const $btn = $$1(event.target).closest('button');
583
- const id = $btn.data('control');
584
- const btn = this.buttons[id];
562
+ /**
563
+ * Gets the underlying DOM element
564
+ * @returns {jQuery}
565
+ */
566
+ getDom: function getDom() {
567
+ return this.$html;
568
+ },
585
569
 
586
- if (btn) {
587
- this._execute(btn);
588
- }
589
- },
570
+ /**
571
+ * Called when button is clicked.
572
+ * Executes a button related action
573
+ * @param {Event} event
574
+ * @private
575
+ */
576
+ _onButtonClick: function _onButtonClick(event) {
577
+ var $btn = $$1(event.target).closest('button');
578
+ var id = $btn.data('control');
579
+ var btn = this.buttons[id];
580
+
581
+ if (btn) {
582
+ this._execute(btn);
583
+ }
584
+ },
590
585
 
586
+ /**
587
+ * Execute a button related action
588
+ * @param {Object} btn
589
+ * @private
590
+ * @fires dialog#[button.id]btn.modal
591
+ */
592
+ _execute: function _execute(btn) {
593
+ // call the optional callback
594
+ if (btn.action) {
595
+ btn.action.apply(this, [btn, this]);
596
+ }
591
597
  /**
592
- * Execute a button related action
593
- * @param {Object} btn
594
- * @private
595
- * @fires dialog#[button.id]btn.modal
598
+ * Fires the event based on the button name
599
+ * @event dialog#[button.id]btn.modal
600
+ * @param {Object} btn - The related button
596
601
  */
597
- _execute(btn) {
598
- // call the optional callback
599
- if (btn.action) {
600
- btn.action.apply(this, [btn, this]);
601
- }
602
- /**
603
- * Fires the event based on the button name
604
- * @event dialog#[button.id]btn.modal
605
- * @param {Object} btn - The related button
606
- */
607
602
 
608
603
 
609
- this.trigger(btn.id + 'btn' + _scope, [btn]); // auto close the dialog box if the button allows it
604
+ this.trigger(btn.id + 'btn' + _scope, [btn]); // auto close the dialog box if the button allows it
610
605
 
611
- if (btn.close) {
612
- this.hide();
613
- }
614
- },
606
+ if (btn.close) {
607
+ this.hide();
608
+ }
609
+ },
615
610
 
616
- /**
617
- * Set focus on the dialog
618
- * @param {String} [button] - The identifier of the button to focus. If none is provided, the focus will be put
619
- * on the first navigable element.
620
- */
621
- focus(button) {
622
- let position = -1;
611
+ /**
612
+ * Set focus on the dialog
613
+ * @param {String} [button] - The identifier of the button to focus. If none is provided, the focus will be put
614
+ * on the first navigable element.
615
+ */
616
+ focus: function focus(button) {
617
+ var position = -1;
623
618
 
624
- if (button) {
625
- position = _.findIndex(this.navigator.getNavigableElements(), navigable => {
626
- return navigable.getElement().is('[data-control="' + button + '"]');
627
- });
628
- }
619
+ if (button) {
620
+ position = _.findIndex(this.navigator.getNavigableElements(), function (navigable) {
621
+ return navigable.getElement().is('[data-control="' + button + '"]');
622
+ });
623
+ }
629
624
 
630
- if (position >= 0) {
631
- this.navigator.setCursorAt(position);
632
- } else {
633
- this.navigator.focus();
634
- }
635
- },
625
+ if (position >= 0) {
626
+ this.navigator.setCursorAt(position);
627
+ } else {
628
+ this.navigator.focus();
629
+ }
630
+ },
636
631
 
637
- /**
638
- * Installs the dialog box
639
- * @private
640
- * #fires dialog#create.dialog
641
- */
642
- _install() {
643
- if (!this.destroyed) {
644
- this.$html.modal({
645
- width: this.width,
646
- animate: this.animate,
647
- disableClosing: this.disableClosing,
648
- disableEscape: this.disableEscape
649
- }).on('closed' + _scope, () => {
650
- if (this.autoDestroy) {
651
- this.destroy();
652
- }
653
- });
654
- const $items = this.getDom().add($$1(_scope).find('input')).add(this.$buttons.find('button'));
655
- const closeButton = $$1(_scope).find('#modal-close-btn')[0];
656
-
657
- if (closeButton) {
658
- $items.push(closeButton);
659
- } //creates the navigator to manage the key navigation
660
-
661
-
662
- this.navigator = keyNavigator({
663
- elements: navigableDomElement.createFromDoms($items),
664
- propagateTab: false
665
- }).on('right down', function () {
666
- if (this.getCursor().position === $items.length - 1) {
667
- this.setCursorAt(1); // Skip container.
668
- } else {
669
- this.next();
670
- }
671
- }).on('left up', function () {
672
- if (this.getCursor().position === 1) {
673
- // Skip container.
674
- this.last();
675
- } else {
676
- this.previous();
677
- }
678
- }).on('tab', function () {
679
- if (this.getCursor().position === $items.length - 1) {
680
- this.setCursorAt(1); // Skip container.
681
- } else {
682
- this.next();
683
- }
684
- }).on('shift+tab', function () {
685
- if (this.getCursor().position === 1) {
686
- // Skip container.
687
- this.last();
688
- } else {
689
- this.previous();
690
- }
691
- }).on('activate', _.debounce(function (cursor) {
692
- const $elt = cursor.navigable.getElement();
693
-
694
- if (!$elt.is(':radio,:checkbox')) {
695
- $elt.click();
696
- } else {
697
- $elt.prop('checked', !$elt.prop('checked')).change();
698
- }
699
- }, 10));
700
- this.navigator.first(); //added a global shortcut to enable setting focus on tab
701
-
702
- this.globalShortcut = shortcutRegistry($$1('body')).add('tab shift+tab', () => {
703
- if (!this.navigator.isFocused()) {
704
- this.navigator.focus();
705
- }
706
- });
707
- this.trigger('create.dialog');
708
- }
709
- },
632
+ /**
633
+ * Installs the dialog box
634
+ * @private
635
+ * #fires dialog#create.dialog
636
+ */
637
+ _install: function _install() {
638
+ var _this3 = this;
639
+
640
+ if (!this.destroyed) {
641
+ this.$html.modal({
642
+ width: this.width,
643
+ animate: this.animate,
644
+ disableClosing: this.disableClosing,
645
+ disableEscape: this.disableEscape
646
+ }).on('closed' + _scope, function () {
647
+ if (_this3.autoDestroy) {
648
+ _this3.destroy();
649
+ }
650
+ });
651
+ var $items = this.getDom().add($$1(_scope).find('input')).add(this.$buttons.find('button'));
652
+ var closeButton = $$1(_scope).find('#modal-close-btn')[0];
710
653
 
711
- /**
712
- * Opens the dialog box
713
- * @private
714
- */
715
- _open() {
716
- this.$html.modal('open');
717
- },
654
+ if (closeButton) {
655
+ $items.push(closeButton);
656
+ } //creates the navigator to manage the key navigation
718
657
 
719
- /**
720
- * Closes the dialog box
721
- * @private
722
- */
723
- _close() {
724
- this.$html.modal('close');
725
- },
726
658
 
727
- /**
728
- * Destroys the dialog box
729
- * @private
730
- */
731
- _destroy() {
732
- this.$html.modal('destroy');
659
+ this.navigator = keyNavigator({
660
+ elements: navigableDomElement.createFromDoms($items),
661
+ propagateTab: false
662
+ }).on('right down', function () {
663
+ if (this.getCursor().position === $items.length - 1) {
664
+ this.setCursorAt(1); // Skip container.
665
+ } else {
666
+ this.next();
667
+ }
668
+ }).on('left up', function () {
669
+ if (this.getCursor().position === 1) {
670
+ // Skip container.
671
+ this.last();
672
+ } else {
673
+ this.previous();
674
+ }
675
+ }).on('tab', function () {
676
+ if (this.getCursor().position === $items.length - 1) {
677
+ this.setCursorAt(1); // Skip container.
678
+ } else {
679
+ this.next();
680
+ }
681
+ }).on('shift+tab', function () {
682
+ if (this.getCursor().position === 1) {
683
+ // Skip container.
684
+ this.last();
685
+ } else {
686
+ this.previous();
687
+ }
688
+ }).on('activate', _.debounce(function (cursor) {
689
+ var $elt = cursor.navigable.getElement();
733
690
 
734
- if (this.navigator) {
735
- this.navigator.destroy();
736
- }
691
+ if (!$elt.is(':radio,:checkbox')) {
692
+ $elt.click();
693
+ } else {
694
+ $elt.prop('checked', !$elt.prop('checked')).change();
695
+ }
696
+ }, 10));
697
+ this.navigator.first(); //added a global shortcut to enable setting focus on tab
737
698
 
738
- if (this.globalShortcut) {
739
- this.globalShortcut.clear();
740
- }
699
+ this.globalShortcut = shortcutRegistry($$1('body')).add('tab shift+tab', function () {
700
+ if (!_this3.navigator.isFocused()) {
701
+ _this3.navigator.focus();
702
+ }
703
+ });
704
+ this.trigger('create.dialog');
741
705
  }
706
+ },
742
707
 
743
- };
744
708
  /**
745
- * Builds a dialog box instance
746
- * @param {Object} options
747
- * @returns {dialog}
709
+ * Opens the dialog box
710
+ * @private
748
711
  */
712
+ _open: function _open() {
713
+ this.$html.modal('open');
714
+ },
749
715
 
750
- function dialogFactory(options) {
751
- const instance = Object.assign({}, dialog);
752
- instance.init(options);
753
- return instance;
754
- }
716
+ /**
717
+ * Closes the dialog box
718
+ * @private
719
+ */
720
+ _close: function _close() {
721
+ this.$html.modal('close');
722
+ },
723
+
724
+ /**
725
+ * Destroys the dialog box
726
+ * @private
727
+ */
728
+ _destroy: function _destroy() {
729
+ this.$html.modal('destroy');
730
+
731
+ if (this.navigator) {
732
+ this.navigator.destroy();
733
+ }
755
734
 
756
- return dialogFactory;
735
+ if (this.globalShortcut) {
736
+ this.globalShortcut.clear();
737
+ }
738
+ }
739
+ };
740
+ /**
741
+ * Builds a dialog box instance
742
+ * @param {Object} options
743
+ * @returns {dialog}
744
+ */
745
+
746
+ function dialogFactory(options) {
747
+ var instance = Object.assign({}, dialog);
748
+ instance.init(options);
749
+ return instance;
750
+ }
751
+
752
+ return dialogFactory;
757
753
 
758
754
  });