@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/tabs.js CHANGED
@@ -1,693 +1,716 @@
1
1
  define(['jquery', 'lodash', 'ui/component', 'handlebars', 'i18n', 'lib/dompurify/purify', 'css!ui/tabs/css/tabs.css'], function ($$1, _, componentFactory, Handlebars, __, DOMPurify, tabs_css) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
6
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
8
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
9
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
6
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
8
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
9
+
10
+ function _typeof(obj) {
11
+ "@babel/helpers - typeof";
12
+
13
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14
+ return typeof obj;
15
+ } : function (obj) {
16
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17
+ }, _typeof(obj);
18
+ }
19
+
20
+ function _toConsumableArray(arr) {
21
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
22
+ }
23
+
24
+ function _arrayWithoutHoles(arr) {
25
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
26
+ }
27
+
28
+ function _iterableToArray(iter) {
29
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
30
+ }
31
+
32
+ function _unsupportedIterableToArray(o, minLen) {
33
+ if (!o) return;
34
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
35
+ var n = Object.prototype.toString.call(o).slice(8, -1);
36
+ if (n === "Object" && o.constructor) n = o.constructor.name;
37
+ if (n === "Map" || n === "Set") return Array.from(o);
38
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39
+ }
40
+
41
+ function _arrayLikeToArray(arr, len) {
42
+ if (len == null || len > arr.length) len = arr.length;
43
+
44
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
45
+
46
+ return arr2;
47
+ }
48
+
49
+ function _nonIterableSpread() {
50
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
+ }
52
+
53
+ function Helpers0 (hb) {
54
+ //register a i18n helper
55
+ hb.registerHelper('__', function (key) {
56
+ return __(key);
57
+ });
10
58
  /**
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License
13
- * as published by the Free Software Foundation; under version 2
14
- * of the License (non-upgradable).
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
- *
25
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
59
+ * Register dompurify helper
26
60
  *
61
+ * https://github.com/cure53/DOMPurify
62
+ * with config SAFE_FOR_TEMPLATES: true
63
+ * to make output safe for template systems
64
+ */
65
+
66
+ hb.registerHelper('dompurify', function (context) {
67
+ return DOMPurify.sanitize(context);
68
+ });
69
+ /**
70
+ * Register join helper
27
71
  *
72
+ * Example :
73
+ * var values = {a:v1, b:v2, c:v3};
74
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
75
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
28
76
  */
29
- function Helpers0 (hb) {
30
- //register a i18n helper
31
- hb.registerHelper('__', function (key) {
32
- return __(key);
33
- });
34
- /**
35
- * Register dompurify helper
36
- *
37
- * https://github.com/cure53/DOMPurify
38
- * with config SAFE_FOR_TEMPLATES: true
39
- * to make output safe for template systems
40
- */
41
77
 
42
- hb.registerHelper('dompurify', function (context) {
43
- return DOMPurify.sanitize(context);
44
- });
45
- /**
46
- * Register join helper
47
- *
48
- * Example :
49
- * var values = {a:v1, b:v2, c:v3};
50
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
51
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
52
- */
78
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
79
+ var fragments = [];
80
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
81
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
82
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
53
83
 
54
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
55
- var fragments = [];
56
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
57
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
58
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
59
-
60
- _.forIn(arr, function (value, key) {
61
- var fragment = '';
62
-
63
- if (value !== null || value !== undefined) {
64
- if (typeof value === 'boolean') {
65
- value = value ? 'true' : 'false';
66
- } else if (typeof value === 'object') {
67
- value = _.values(value).join(' ');
68
- }
69
- } else {
70
- value = '';
71
- }
84
+ _.forIn(arr, function (value, key) {
85
+ var fragment = '';
72
86
 
73
- if (keyValueGlue !== undefined) {
74
- fragment += key + keyValueGlue;
87
+ if (value !== null || value !== undefined) {
88
+ if (typeof value === 'boolean') {
89
+ value = value ? 'true' : 'false';
90
+ } else if (_typeof(value) === 'object') {
91
+ value = _.values(value).join(' ');
75
92
  }
93
+ } else {
94
+ value = '';
95
+ }
76
96
 
77
- fragment += wrapper + value + wrapper;
78
- fragments.push(fragment);
79
- });
80
-
81
- return fragments.join(fragmentGlue);
82
- }); //register a classic "for loop" helper
83
- //it also adds a local variable "i" as the index in each iteration loop
84
-
85
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
86
- var ret = '';
87
- startIndex = parseInt(startIndex);
88
- stopIndex = parseInt(stopIndex);
89
- increment = parseInt(increment);
90
-
91
- for (var i = startIndex; i < stopIndex; i += increment) {
92
- ret += options.fn(_.extend({}, this, {
93
- i: i
94
- }));
97
+ if (keyValueGlue !== undefined) {
98
+ fragment += key + keyValueGlue;
95
99
  }
96
100
 
97
- return ret;
101
+ fragment += wrapper + value + wrapper;
102
+ fragments.push(fragment);
98
103
  });
99
- hb.registerHelper('equal', function (var1, var2, options) {
100
- if (var1 == var2) {
101
- return options.fn(this);
102
- } else {
103
- return options.inverse(this);
104
- }
105
- }); // register a "get property" helper
106
- // it gets the named property from the provided context
107
104
 
108
- hb.registerHelper('property', function (name, context) {
109
- return context[name] || '';
110
- }); // register an 'includes' helper
111
- // it checks if value is in array
105
+ return fragments.join(fragmentGlue);
106
+ }); //register a classic "for loop" helper
107
+ //it also adds a local variable "i" as the index in each iteration loop
112
108
 
113
- hb.registerHelper('includes', function (haystack, needle, options) {
114
- if (_.contains(haystack, needle)) {
115
- return options.fn(this);
116
- }
117
- });
118
- }
109
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
110
+ var ret = '';
111
+ startIndex = parseInt(startIndex);
112
+ stopIndex = parseInt(stopIndex);
113
+ increment = parseInt(increment);
119
114
 
120
- if (!Helpers0.__initialized) {
121
- Helpers0(Handlebars);
122
- Helpers0.__initialized = true;
123
- }
124
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
125
- this.compilerInfo = [4,'>= 1.0.0'];
126
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
127
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
128
-
129
- function program1(depth0,data) {
130
-
131
- var buffer = "", stack1, helper;
132
- buffer += "\n <li class=\"tab ";
133
- if (helper = helpers.cls) { stack1 = helper.call(depth0, {hash:{},data:data}); }
134
- else { helper = (depth0 && depth0.cls); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
135
- buffer += escapeExpression(stack1)
136
- + "\" data-tab-name=\"";
137
- if (helper = helpers.name) { stack1 = helper.call(depth0, {hash:{},data:data}); }
138
- else { helper = (depth0 && depth0.name); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
139
- buffer += escapeExpression(stack1)
140
- + "\">\n <button class=\"action\" tabindex=\"0\" ";
141
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.disabled), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
142
- if(stack1 || stack1 === 0) { buffer += stack1; }
143
- buffer += ">\n ";
144
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.icon), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
145
- if(stack1 || stack1 === 0) { buffer += stack1; }
146
- buffer += "\n ";
147
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.label), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
148
- if(stack1 || stack1 === 0) { buffer += stack1; }
149
- buffer += "\n </button>\n </li>\n ";
150
- return buffer;
151
- }
152
- function program2(depth0,data) {
153
-
154
-
155
- return "disabled";
115
+ for (var i = startIndex; i < stopIndex; i += increment) {
116
+ ret += options.fn(_.extend({}, this, {
117
+ i: i
118
+ }));
156
119
  }
157
120
 
158
- function program4(depth0,data) {
159
-
160
- var buffer = "", stack1, helper;
161
- buffer += "<span class=\"icon icon-";
162
- if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
163
- else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
164
- buffer += escapeExpression(stack1)
165
- + "\"></span>";
166
- return buffer;
121
+ return ret;
122
+ });
123
+ hb.registerHelper('equal', function (var1, var2, options) {
124
+ if (var1 == var2) {
125
+ return options.fn(this);
126
+ } else {
127
+ return options.inverse(this);
167
128
  }
129
+ }); // register a "get property" helper
130
+ // it gets the named property from the provided context
131
+
132
+ hb.registerHelper('property', function (name, context) {
133
+ return context[name] || '';
134
+ }); // register an 'includes' helper
135
+ // it checks if value is in array
168
136
 
169
- function program6(depth0,data) {
170
-
171
- var buffer = "", stack1, helper;
172
- buffer += "<span class=\"label\">";
173
- if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
174
- else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
175
- buffer += escapeExpression(stack1)
176
- + "</span>";
177
- return buffer;
137
+ hb.registerHelper('includes', function (haystack, needle, options) {
138
+ if (_.contains(haystack, needle)) {
139
+ return options.fn(this);
178
140
  }
141
+ });
142
+ }
143
+
144
+ if (!Helpers0.__initialized) {
145
+ Helpers0(Handlebars);
146
+ Helpers0.__initialized = true;
147
+ }
148
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
149
+ this.compilerInfo = [4,'>= 1.0.0'];
150
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
151
+ var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
152
+
153
+ function program1(depth0,data) {
154
+
155
+ var buffer = "", stack1, helper;
156
+ buffer += "\n <li class=\"tab ";
157
+ if (helper = helpers.cls) { stack1 = helper.call(depth0, {hash:{},data:data}); }
158
+ else { helper = (depth0 && depth0.cls); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
159
+ buffer += escapeExpression(stack1)
160
+ + "\" data-tab-name=\"";
161
+ if (helper = helpers.name) { stack1 = helper.call(depth0, {hash:{},data:data}); }
162
+ else { helper = (depth0 && depth0.name); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
163
+ buffer += escapeExpression(stack1)
164
+ + "\">\n <button class=\"action\" tabindex=\"0\" ";
165
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.disabled), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
166
+ if(stack1 || stack1 === 0) { buffer += stack1; }
167
+ buffer += ">\n ";
168
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.icon), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
169
+ if(stack1 || stack1 === 0) { buffer += stack1; }
170
+ buffer += "\n ";
171
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.label), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
172
+ if(stack1 || stack1 === 0) { buffer += stack1; }
173
+ buffer += "\n </button>\n </li>\n ";
174
+ return buffer;
175
+ }
176
+ function program2(depth0,data) {
177
+
178
+
179
+ return "disabled";
180
+ }
179
181
 
180
- buffer += "<ul class=\"tab-group\">\n ";
181
- stack1 = helpers.each.call(depth0, (depth0 && depth0.tabs), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
182
- if(stack1 || stack1 === 0) { buffer += stack1; }
183
- buffer += "\n</ul>\n";
184
- return buffer;
185
- });
186
- function tabsTpl(data, options, asString) {
187
- var html = Template(data, options);
188
- return (asString || true) ? html : $(html);
182
+ function program4(depth0,data) {
183
+
184
+ var buffer = "", stack1, helper;
185
+ buffer += "<span class=\"icon icon-";
186
+ if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
187
+ else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
188
+ buffer += escapeExpression(stack1)
189
+ + "\"></span>";
190
+ return buffer;
189
191
  }
190
192
 
191
- /**
192
- * This program is free software; you can redistribute it and/or
193
- * modify it under the terms of the GNU General Public License
194
- * as published by the Free Software Foundation; under version 2
195
- * of the License (non-upgradable).
196
- *
197
- * This program is distributed in the hope that it will be useful,
198
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
199
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
200
- * GNU General Public License for more details.
201
- *
202
- * You should have received a copy of the GNU General Public License
203
- * along with this program; if not, write to the Free Software
204
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
205
- *
206
- * Copyright (c) 2019 (original work) Open Assessment Technologies SA ;
207
- */
208
- /**
209
- * @typedef {Object} tabsBarConfig
210
- * @property {String} [activeTab] - The name of the active tab
211
- * @property {Integer} [activeTabIndex] - the index of the tab to start on
212
- * @property {tabConfig[]} [tabs] - The list of tabs
213
- * @property {Boolean} [hideLoneTab] - Prevent to show the tabs when only one is registered
214
- * @property {jQuery|HTMLElement|String|Boolean} [showHideTarget] - Defines the container where to wire up tabs to
215
- * content, the link will be automatic, based on the data attribute `data-tab-content` that should match the tab name.
216
- * If the value is `true` the component's container will be used to find the panels.
217
- */
193
+ function program6(depth0,data) {
194
+
195
+ var buffer = "", stack1, helper;
196
+ buffer += "<span class=\"label\">";
197
+ if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
198
+ else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
199
+ buffer += escapeExpression(stack1)
200
+ + "</span>";
201
+ return buffer;
202
+ }
218
203
 
204
+ buffer += "<ul class=\"tab-group\">\n ";
205
+ stack1 = helpers.each.call(depth0, (depth0 && depth0.tabs), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
206
+ if(stack1 || stack1 === 0) { buffer += stack1; }
207
+ buffer += "\n</ul>\n";
208
+ return buffer;
209
+ });
210
+ function tabsTpl(data, options, asString) {
211
+ var html = Template(data, options);
212
+ return (asString || true) ? html : $(html);
213
+ }
214
+
215
+ /**
216
+ * @typedef {Object} tabsBarConfig
217
+ * @property {String} [activeTab] - The name of the active tab
218
+ * @property {Integer} [activeTabIndex] - the index of the tab to start on
219
+ * @property {tabConfig[]} [tabs] - The list of tabs
220
+ * @property {Boolean} [hideLoneTab] - Prevent to show the tabs when only one is registered
221
+ * @property {jQuery|HTMLElement|String|Boolean} [showHideTarget] - Defines the container where to wire up tabs to
222
+ * content, the link will be automatic, based on the data attribute `data-tab-content` that should match the tab name.
223
+ * If the value is `true` the component's container will be used to find the panels.
224
+ */
225
+
226
+ /**
227
+ * @typedef {Object} tabConfig
228
+ * @property {Boolean} disabled - The tab is disabled
229
+ * @property {String} name - The tab identifier
230
+ * @property {String} label - The tab label
231
+ * @property {String} [icon] - An optional tab icon
232
+ * @property {String} [cls] - An optional CSS class name
233
+ */
234
+
235
+ /**
236
+ * CSS class for the active tab
237
+ * @type {String}
238
+ */
239
+
240
+ var activeTabCls = 'active';
241
+ /**
242
+ * CSS selector for the tabs
243
+ * @type {String}
244
+ */
245
+
246
+ var tabSelector = '.tab';
247
+ /**
248
+ * CSS selector for the tab actions
249
+ * @type {String}
250
+ */
251
+
252
+ var actionSelector = '.action';
253
+ /**
254
+ * Name of the attribute that contain the tab identifier
255
+ * @type {String}
256
+ */
257
+
258
+ var tabNameAttr = 'data-tab-name';
259
+ /**
260
+ * Name of the attribute that contain the panel identifier
261
+ * @type {String}
262
+ */
263
+
264
+ var panelNameAttr = 'data-tab-content';
265
+ /**
266
+ * Builds an instance of the tabs component.
267
+ *
268
+ * @example
269
+ * // activate by index
270
+ * const instance = tabsFactory($container, {
271
+ * tabs: [
272
+ * { label: 'TAO Local', name: 'local-delivery' },
273
+ * { label: 'TAO Remote', name: 'remote-delivery' },
274
+ * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
275
+ * ],
276
+ * activeTabIndex: 1
277
+ * });
278
+ *
279
+ * // activate by name
280
+ * const instance = tabsFactory($container, {
281
+ * tabs: [
282
+ * { label: 'TAO Local', name: 'local-delivery' },
283
+ * { label: 'TAO Remote', name: 'remote-delivery' },
284
+ * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
285
+ * ],
286
+ * activeTab: 'remote-delivery'
287
+ * });
288
+ *
289
+ * // link to panels
290
+ * const instance = tabsFactory($container, {
291
+ * showHideTarget: $panelContainer,
292
+ * tabs: [
293
+ * { label: 'TAO Local', name: 'local-delivery' },
294
+ * { label: 'TAO Remote', name: 'remote-delivery' },
295
+ * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
296
+ * ]
297
+ * });
298
+ *
299
+ * instance
300
+ * .on('ready', function onReady() {
301
+ * // the component is ready
302
+ * })
303
+ * .before('tabactivate', function beforeTabChange(e, name) {
304
+ * // a tab is being activated
305
+ * // it is possible to prevent its activation by returning a rejected promise
306
+ * if (name === 'lti-delivery') {
307
+ * return Promise.reject();
308
+ * }
309
+ * })
310
+ * .on('tabchange', function onTabChange(name) {
311
+ * // a tab has been activated
312
+ * });
313
+ *
314
+ * @param {HTMLElement|String} container
315
+ * @param {tabsBarConfig} config
316
+ * @param {String} [config.activeTab] - The name of the active tab
317
+ * @param {Integer} [config.activeTabIndex] - the index of the tab to start on
318
+ * @param {tabConfig[]} [config.tabs] - The list of tabs
319
+ * @param {Boolean} [config.hideLoneTab] - Prevent to show the tabs when only one is registered
320
+ * @param {jQuery|HTMLElement|String|Boolean} [config.showHideTarget] - Defines the container where to wire up tabs to
321
+ * content, the link will be automatic, based on the data attribute `data-tab-content` that should match the tab name.
322
+ * If the value is `true` the component's container will be used to find the panels.
323
+ * @returns {tabsBarComponent}
324
+ * @fires ready - When the component is ready to work
325
+ * @fires error - When the component encounters issue
326
+ * @fires tabactivate - Each time a tab must be activated
327
+ * @fires tabchange - Each time a tab has been activated
328
+ * @fires tabchange-${name} - Each time the named tab has been activated
329
+ * @fires tabsupdate - Each time the tabs are updated
330
+ */
331
+
332
+ function tabsFactory(container, config) {
333
+ // the list of displayed tabs
334
+ var tabs = []; // the current active tab
335
+
336
+ var activeTabName = null; // enable/disable elements
337
+
338
+ var enableElement = function enableElement($el) {
339
+ return $el.prop('disabled', false);
340
+ };
341
+
342
+ var disableElement = function disableElement($el) {
343
+ return $el.prop('disabled', true);
344
+ };
219
345
  /**
220
- * @typedef {Object} tabConfig
221
- * @property {Boolean} disabled - The tab is disabled
222
- * @property {String} name - The tab identifier
223
- * @property {String} label - The tab label
224
- * @property {String} [icon] - An optional tab icon
225
- * @property {String} [cls] - An optional CSS class name
346
+ * Gets a tab by its name
347
+ * @param {String} name
348
+ * @returns {tabConfig}
226
349
  */
227
350
 
228
- /**
229
- * CSS class for the active tab
230
- * @type {String}
231
- */
232
351
 
233
- const activeTabCls = 'active';
352
+ var findTabByName = function findTabByName(name) {
353
+ return tabs.find(function (tab) {
354
+ return tab.name === name;
355
+ });
356
+ };
234
357
  /**
235
- * CSS selector for the tabs
236
- * @type {String}
358
+ * Gets a tab by its name, throw a TypeError if the tab does not exist
359
+ * @param {String} name - human-readable identifier
360
+ * @returns {tabConfig}
361
+ * @throws {TypeError} on invalid name param
237
362
  */
238
363
 
239
- const tabSelector = '.tab';
240
- /**
241
- * CSS selector for the tab actions
242
- * @type {String}
243
- */
244
364
 
245
- const actionSelector = '.action';
246
- /**
247
- * Name of the attribute that contain the tab identifier
248
- * @type {String}
249
- */
365
+ var findTabByNameOrThrow = function findTabByNameOrThrow(name) {
366
+ var tab = findTabByName(name);
250
367
 
251
- const tabNameAttr = 'data-tab-name';
252
- /**
253
- * Name of the attribute that contain the panel identifier
254
- * @type {String}
255
- */
368
+ if (!tab) {
369
+ throw new TypeError("No tab exists with the name: ".concat(name));
370
+ }
256
371
 
257
- const panelNameAttr = 'data-tab-content';
372
+ return tab;
373
+ };
258
374
  /**
259
- * Builds an instance of the tabs component.
260
- *
261
- * @example
262
- * // activate by index
263
- * const instance = tabsFactory($container, {
264
- * tabs: [
265
- * { label: 'TAO Local', name: 'local-delivery' },
266
- * { label: 'TAO Remote', name: 'remote-delivery' },
267
- * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
268
- * ],
269
- * activeTabIndex: 1
270
- * });
271
- *
272
- * // activate by name
273
- * const instance = tabsFactory($container, {
274
- * tabs: [
275
- * { label: 'TAO Local', name: 'local-delivery' },
276
- * { label: 'TAO Remote', name: 'remote-delivery' },
277
- * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
278
- * ],
279
- * activeTab: 'remote-delivery'
280
- * });
281
- *
282
- * // link to panels
283
- * const instance = tabsFactory($container, {
284
- * showHideTarget: $panelContainer,
285
- * tabs: [
286
- * { label: 'TAO Local', name: 'local-delivery' },
287
- * { label: 'TAO Remote', name: 'remote-delivery' },
288
- * { label: 'LTI-based', name: 'lti-delivery', disabled: true }
289
- * ]
290
- * });
291
- *
292
- * instance
293
- * .on('ready', function onReady() {
294
- * // the component is ready
295
- * })
296
- * .before('tabactivate', function beforeTabChange(e, name) {
297
- * // a tab is being activated
298
- * // it is possible to prevent its activation by returning a rejected promise
299
- * if (name === 'lti-delivery') {
300
- * return Promise.reject();
301
- * }
302
- * })
303
- * .on('tabchange', function onTabChange(name) {
304
- * // a tab has been activated
305
- * });
306
- *
307
- * @param {HTMLElement|String} container
308
- * @param {tabsBarConfig} config
309
- * @param {String} [config.activeTab] - The name of the active tab
310
- * @param {Integer} [config.activeTabIndex] - the index of the tab to start on
311
- * @param {tabConfig[]} [config.tabs] - The list of tabs
312
- * @param {Boolean} [config.hideLoneTab] - Prevent to show the tabs when only one is registered
313
- * @param {jQuery|HTMLElement|String|Boolean} [config.showHideTarget] - Defines the container where to wire up tabs to
314
- * content, the link will be automatic, based on the data attribute `data-tab-content` that should match the tab name.
315
- * If the value is `true` the component's container will be used to find the panels.
316
- * @returns {tabsBarComponent}
317
- * @fires ready - When the component is ready to work
318
- * @fires error - When the component encounters issue
319
- * @fires tabactivate - Each time a tab must be activated
320
- * @fires tabchange - Each time a tab has been activated
321
- * @fires tabchange-${name} - Each time the named tab has been activated
322
- * @fires tabsupdate - Each time the tabs are updated
375
+ * Initializes the tabs
376
+ * @param {tabsBarComponent} component
323
377
  */
324
378
 
325
- function tabsFactory(container, config) {
326
- // the list of displayed tabs
327
- let tabs = []; // the current active tab
328
379
 
329
- let activeTabName = null; // enable/disable elements
380
+ var initTabs = function initTabs(component) {
381
+ if (activeTabName) {
382
+ var activeTab = activeTabName;
383
+ activeTabName = null;
384
+ component.setActiveTab(activeTab);
385
+ }
386
+
387
+ if (component.getConfig().hideLoneTab && tabs.length === 1) {
388
+ component.hide();
389
+ }
390
+ };
391
+ /**
392
+ * API of the tabs component
393
+ * @exports ui/tabs
394
+ */
330
395
 
331
- const enableElement = $el => $el.prop('disabled', false);
332
396
 
333
- const disableElement = $el => $el.prop('disabled', true);
397
+ var tabsApi = {
334
398
  /**
335
- * Gets a tab by its name
336
- * @param {String} name
337
- * @returns {tabConfig}
399
+ * Set new values for the tabs
400
+ * @param {Array} newTabs
401
+ * @returns {tabsBarComponent} instance
402
+ * @throws {TypeError} on non-Array tabs
403
+ * @fires tabsupdate once the tabs have been updated
404
+ * @fires tabactivate once the active tab is updated
338
405
  */
406
+ setTabs: function setTabs(newTabs) {
407
+ if (!Array.isArray(newTabs)) {
408
+ throw new TypeError('The provided tabs are not a valid array');
409
+ }
339
410
 
411
+ tabs = _toConsumableArray(newTabs); // reset tab to default if needed
340
412
 
341
- const findTabByName = name => tabs.find(tab => tab.name === name);
342
- /**
343
- * Gets a tab by its name, throw a TypeError if the tab does not exist
344
- * @param {String} name - human-readable identifier
345
- * @returns {tabConfig}
346
- * @throws {TypeError} on invalid name param
347
- */
413
+ if (!activeTabName || !findTabByName(activeTabName)) {
414
+ activeTabName = this.getDefaultActiveTab();
415
+ } // replace the displayed tabs if already rendered
348
416
 
349
417
 
350
- const findTabByNameOrThrow = name => {
351
- const tab = findTabByName(name);
418
+ if (this.is('rendered')) {
419
+ var template = this.getTemplate();
420
+ this.getElement().html($$1(template({
421
+ tabs: tabs
422
+ })).html()); // make sure the tab is selected and hide lone tab if needed
352
423
 
353
- if (!tab) {
354
- throw new TypeError(`No tab exists with the name: ${name}`);
424
+ initTabs(this);
355
425
  }
426
+ /**
427
+ * @event tabsupdate - Tabs have been updated
428
+ * @param {Array} newTabs
429
+ */
430
+
431
+
432
+ this.trigger('tabsupdate', newTabs);
433
+ return this;
434
+ },
356
435
 
357
- return tab;
358
- };
359
436
  /**
360
- * Initializes the tabs
361
- * @param {tabsBarComponent} component
437
+ * Retrieve internal tabs array
438
+ * @returns {Array} tabs list
362
439
  */
440
+ getTabs: function getTabs() {
441
+ return _toConsumableArray(tabs);
442
+ },
363
443
 
444
+ /**
445
+ * Gets the name of the active tab (if any)
446
+ * @returns {String}
447
+ */
448
+ getActiveTab: function getActiveTab() {
449
+ return activeTabName;
450
+ },
364
451
 
365
- const initTabs = component => {
366
- if (activeTabName) {
367
- const activeTab = activeTabName;
368
- activeTabName = null;
369
- component.setActiveTab(activeTab);
370
- }
452
+ /**
453
+ * Gets the index of the current active tab (if any)
454
+ * @returns {Number}
455
+ */
456
+ getActiveTabIndex: function getActiveTabIndex() {
457
+ return tabs.findIndex(function (tab) {
458
+ return tab.name === activeTabName;
459
+ });
460
+ },
371
461
 
372
- if (component.getConfig().hideLoneTab && tabs.length === 1) {
373
- component.hide();
374
- }
375
- };
376
462
  /**
377
- * API of the tabs component
378
- * @exports ui/tabs
463
+ * Gets the name of the default active tab
464
+ * @returns {String|null}
379
465
  */
466
+ getDefaultActiveTab: function getDefaultActiveTab() {
467
+ var _this$getConfig = this.getConfig(),
468
+ activeTab = _this$getConfig.activeTab,
469
+ activeTabIndex = _this$getConfig.activeTabIndex;
380
470
 
471
+ if (activeTab && findTabByName(activeTab)) {
472
+ return activeTab;
473
+ }
381
474
 
382
- const tabsApi = {
383
- /**
384
- * Set new values for the tabs
385
- * @param {Array} newTabs
386
- * @returns {tabsBarComponent} instance
387
- * @throws {TypeError} on non-Array tabs
388
- * @fires tabsupdate once the tabs have been updated
389
- * @fires tabactivate once the active tab is updated
390
- */
391
- setTabs(newTabs) {
392
- if (!Array.isArray(newTabs)) {
393
- throw new TypeError('The provided tabs are not a valid array');
394
- }
475
+ if (typeof activeTabIndex === 'number' && tabs[activeTabIndex]) {
476
+ return tabs[activeTabIndex].name;
477
+ }
478
+
479
+ return tabs.length && tabs[0].name || null;
480
+ },
481
+
482
+ /**
483
+ * Activates a single tab by its name (deactivating others)
484
+ * @param {String} name - human-readable identifier
485
+ * @returns {tabsBarComponent} instance
486
+ * @throws {TypeError} on invalid name param
487
+ * @fires tabactivate
488
+ */
489
+ setActiveTab: function setActiveTab(name) {
490
+ var tab = findTabByNameOrThrow(name);
395
491
 
396
- tabs = [...newTabs]; // reset tab to default if needed
492
+ if (!tab.disabled) {
493
+ /**
494
+ * @event tabactivate - A tab is being activated
495
+ * @param {String} - name
496
+ */
497
+ this.trigger('tabactivate', tab.name);
498
+ }
397
499
 
398
- if (!activeTabName || !findTabByName(activeTabName)) {
399
- activeTabName = this.getDefaultActiveTab();
400
- } // replace the displayed tabs if already rendered
500
+ return this;
501
+ },
401
502
 
503
+ /**
504
+ * Activates a single tab by its index (deactivating others)
505
+ * Triggers the automatic showing & hiding of target tab-contents
506
+ * @param {Number} index - zero-based
507
+ * @returns {tabsBarComponent} instance
508
+ * @throws {TypeError} on invalid index param
509
+ * @fires tabactivate
510
+ */
511
+ setActiveTabIndex: function setActiveTabIndex(index) {
512
+ if (typeof index !== 'number' || index < 0 || index >= tabs.length) {
513
+ throw new TypeError("No tab exists at index: ".concat(index));
514
+ }
402
515
 
403
- if (this.is('rendered')) {
404
- const template = this.getTemplate();
405
- this.getElement().html($$1(template({
406
- tabs
407
- })).html()); // make sure the tab is selected and hide lone tab if needed
516
+ var tab = tabs[index];
408
517
 
409
- initTabs(this);
410
- }
518
+ if (!tab.disabled) {
411
519
  /**
412
- * @event tabsupdate - Tabs have been updated
413
- * @param {Array} newTabs
520
+ * @event tabactivate - A tab is being activated
521
+ * @param {String} - name
414
522
  */
523
+ this.trigger('tabactivate', tab.name);
524
+ }
415
525
 
526
+ return this;
527
+ },
416
528
 
417
- this.trigger('tabsupdate', newTabs);
418
- return this;
419
- },
529
+ /**
530
+ * Enables a single tab by its name
531
+ * @param {String} name - human-readable identifier
532
+ * @returns {tabsBarComponent} instance
533
+ * @throws {TypeError} on invalid name param
534
+ * @fires tabenable
535
+ */
536
+ enableTab: function enableTab(name) {
537
+ var tab = findTabByNameOrThrow(name);
538
+ tab.disabled = false;
420
539
 
540
+ if (this.is('rendered')) {
541
+ enableElement(this.getElement().find("[".concat(tabNameAttr, "=\"").concat(name, "\"] ").concat(actionSelector)));
542
+ }
421
543
  /**
422
- * Retrieve internal tabs array
423
- * @returns {Array} tabs list
544
+ * @event tabenable - A tab is enabled
545
+ * @param {String} - name
424
546
  */
425
- getTabs() {
426
- return [...tabs];
427
- },
428
547
 
429
- /**
430
- * Gets the name of the active tab (if any)
431
- * @returns {String}
432
- */
433
- getActiveTab() {
434
- return activeTabName;
435
- },
436
548
 
437
- /**
438
- * Gets the index of the current active tab (if any)
439
- * @returns {Number}
440
- */
441
- getActiveTabIndex() {
442
- return tabs.findIndex(tab => tab.name === activeTabName);
443
- },
549
+ this.trigger('tabenable', name);
550
+ return this;
551
+ },
444
552
 
553
+ /**
554
+ * Disables a single tab by its name
555
+ * @param {String} name - human-readable identifier
556
+ * @returns {tabsBarComponent} instance
557
+ * @throws {TypeError} on invalid name param
558
+ * @fires tabdisable
559
+ */
560
+ disableTab: function disableTab(name) {
561
+ var tab = findTabByNameOrThrow(name);
562
+ tab.disabled = true;
563
+
564
+ if (this.is('rendered')) {
565
+ disableElement(this.getElement().find("[".concat(tabNameAttr, "=\"").concat(name, "\"] ").concat(actionSelector)));
566
+ }
445
567
  /**
446
- * Gets the name of the default active tab
447
- * @returns {String|null}
568
+ * @event tabdisable - A tab is disabled
569
+ * @param {String} - name
448
570
  */
449
- getDefaultActiveTab() {
450
- const {
451
- activeTab,
452
- activeTabIndex
453
- } = this.getConfig();
454
-
455
- if (activeTab && findTabByName(activeTab)) {
456
- return activeTab;
457
- }
458
571
 
459
- if (typeof activeTabIndex === 'number' && tabs[activeTabIndex]) {
460
- return tabs[activeTabIndex].name;
461
- }
462
572
 
463
- return tabs.length && tabs[0].name || null;
464
- },
573
+ this.trigger('tabdisable', name);
574
+ },
465
575
 
466
- /**
467
- * Activates a single tab by its name (deactivating others)
468
- * @param {String} name - human-readable identifier
469
- * @returns {tabsBarComponent} instance
470
- * @throws {TypeError} on invalid name param
471
- * @fires tabactivate
472
- */
473
- setActiveTab(name) {
474
- const tab = findTabByNameOrThrow(name);
475
-
476
- if (!tab.disabled) {
477
- /**
478
- * @event tabactivate - A tab is being activated
479
- * @param {String} - name
480
- */
481
- this.trigger('tabactivate', tab.name);
482
- }
576
+ /**
577
+ * Shows one tab content, hides the rest
578
+ * The tab content elements are not tied to any template and can be located anywhere in the DOM
579
+ * @param {String} name - human-readable identifier
580
+ * @throws {TypeError} on invalid name param
581
+ * @fires tabshowcontent
582
+ */
583
+ showTabContent: function showTabContent(name) {
584
+ findTabByNameOrThrow(name);
483
585
 
484
- return this;
485
- },
586
+ var _this$getConfig2 = this.getConfig(),
587
+ showHideTarget = _this$getConfig2.showHideTarget;
486
588
 
589
+ if (showHideTarget) {
590
+ (showHideTarget === true ? this.getContainer() : $$1(showHideTarget)).find("[".concat(panelNameAttr, "]")).addClass('hidden').filter("[".concat(panelNameAttr, "=\"").concat(name, "\"]")).removeClass('hidden');
591
+ }
487
592
  /**
488
- * Activates a single tab by its index (deactivating others)
489
- * Triggers the automatic showing & hiding of target tab-contents
490
- * @param {Number} index - zero-based
491
- * @returns {tabsBarComponent} instance
492
- * @throws {TypeError} on invalid index param
493
- * @fires tabactivate
593
+ * @event tabshowcontent - A tab panel is displayed
594
+ * @param {String} - name
494
595
  */
495
- setActiveTabIndex(index) {
496
- if (typeof index !== 'number' || index < 0 || index >= tabs.length) {
497
- throw new TypeError(`No tab exists at index: ${index}`);
498
- }
499
-
500
- const tab = tabs[index];
501
596
 
502
- if (!tab.disabled) {
503
- /**
504
- * @event tabactivate - A tab is being activated
505
- * @param {String} - name
506
- */
507
- this.trigger('tabactivate', tab.name);
508
- }
509
-
510
- return this;
511
- },
512
597
 
513
- /**
514
- * Enables a single tab by its name
515
- * @param {String} name - human-readable identifier
516
- * @returns {tabsBarComponent} instance
517
- * @throws {TypeError} on invalid name param
518
- * @fires tabenable
519
- */
520
- enableTab(name) {
521
- const tab = findTabByNameOrThrow(name);
522
- tab.disabled = false;
598
+ this.trigger('tabshowcontent', name);
599
+ }
600
+ };
601
+ /**
602
+ * @typedef {component} tabsBarComponent
603
+ */
523
604
 
524
- if (this.is('rendered')) {
525
- enableElement(this.getElement().find(`[${tabNameAttr}="${name}"] ${actionSelector}`));
526
- }
527
- /**
528
- * @event tabenable - A tab is enabled
529
- * @param {String} - name
530
- */
605
+ var tabsBarComponent = componentFactory(tabsApi) // set the component's layout
606
+ .setTemplate(tabsTpl) // auto render on init
607
+ .on('init', function onTabsBarInit() {
608
+ var _this = this;
531
609
 
610
+ try {
611
+ // extract the tabs from the config
612
+ if (this.config && this.config.tabs) {
613
+ this.setTabs(this.config.tabs);
614
+ } // auto render on init (defer the call to give a chance to the init event to be completed before)
532
615
 
533
- this.trigger('tabenable', name);
534
- return this;
535
- },
536
616
 
617
+ _.defer(function () {
618
+ return _this.render(container);
619
+ });
620
+ } catch (err) {
537
621
  /**
538
- * Disables a single tab by its name
539
- * @param {String} name - human-readable identifier
540
- * @returns {tabsBarComponent} instance
541
- * @throws {TypeError} on invalid name param
542
- * @fires tabdisable
622
+ * @event error
623
+ * @param {Error} err
543
624
  */
544
- disableTab(name) {
545
- const tab = findTabByNameOrThrow(name);
546
- tab.disabled = true;
547
-
548
- if (this.is('rendered')) {
549
- disableElement(this.getElement().find(`[${tabNameAttr}="${name}"] ${actionSelector}`));
550
- }
551
- /**
552
- * @event tabdisable - A tab is disabled
553
- * @param {String} - name
554
- */
555
-
556
-
557
- this.trigger('tabdisable', name);
558
- },
559
-
625
+ this.trigger('error', err);
626
+ }
627
+ }) // renders the component
628
+ .on('render', function onTabsBarRender() {
629
+ var _this2 = this;
630
+
631
+ try {
632
+ // make sure the tab is selected and hide lone tab if needed
633
+ initTabs(this);
634
+ } catch (err) {
560
635
  /**
561
- * Shows one tab content, hides the rest
562
- * The tab content elements are not tied to any template and can be located anywhere in the DOM
563
- * @param {String} name - human-readable identifier
564
- * @throws {TypeError} on invalid name param
565
- * @fires tabshowcontent
636
+ * @event error
637
+ * @param {Error} err
566
638
  */
567
- showTabContent(name) {
568
- findTabByNameOrThrow(name);
569
- const {
570
- showHideTarget
571
- } = this.getConfig();
572
-
573
- if (showHideTarget) {
574
- (showHideTarget === true ? this.getContainer() : $$1(showHideTarget)).find(`[${panelNameAttr}]`).addClass('hidden').filter(`[${panelNameAttr}="${name}"]`).removeClass('hidden');
575
- }
576
- /**
577
- * @event tabshowcontent - A tab panel is displayed
578
- * @param {String} - name
579
- */
639
+ this.trigger('error', err);
640
+ } // delegate the click on tabs
580
641
 
581
642
 
582
- this.trigger('tabshowcontent', name);
583
- }
584
-
585
- };
586
- /**
587
- * @typedef {component} tabsBarComponent
588
- */
589
-
590
- const tabsBarComponent = componentFactory(tabsApi) // set the component's layout
591
- .setTemplate(tabsTpl) // auto render on init
592
- .on('init', function onTabsBarInit() {
643
+ this.getElement().on('click', tabSelector, function (e) {
593
644
  try {
594
- // extract the tabs from the config
595
- if (this.config && this.config.tabs) {
596
- this.setTabs(this.config.tabs);
597
- } // auto render on init (defer the call to give a chance to the init event to be completed before)
598
-
599
-
600
- _.defer(() => this.render(container));
645
+ _this2.setActiveTab(e.currentTarget.getAttribute(tabNameAttr));
601
646
  } catch (err) {
602
647
  /**
603
648
  * @event error
604
649
  * @param {Error} err
605
650
  */
606
- this.trigger('error', err);
651
+ _this2.trigger('error', err);
607
652
  }
608
- }) // renders the component
609
- .on('render', function onTabsBarRender() {
610
- try {
611
- // make sure the tab is selected and hide lone tab if needed
612
- initTabs(this);
613
- } catch (err) {
614
- /**
615
- * @event error
616
- * @param {Error} err
617
- */
618
- this.trigger('error', err);
619
- } // delegate the click on tabs
620
-
621
-
622
- this.getElement().on('click', tabSelector, e => {
623
- try {
624
- this.setActiveTab(e.currentTarget.getAttribute(tabNameAttr));
625
- } catch (err) {
626
- /**
627
- * @event error
628
- * @param {Error} err
629
- */
630
- this.trigger('error', err);
631
- }
632
- });
633
- /**
634
- * @event ready - The component is ready to work
635
- */
636
-
637
- this.trigger('ready');
638
- }) // take care of the disable state
639
- .on('disable', function onButtonDisable() {
640
- if (this.is('rendered')) {
641
- disableElement(this.getElement().find(`[${tabNameAttr}] ${actionSelector}`));
642
- }
643
- }).on('enable', function onButtonEnable() {
644
- if (this.is('rendered')) {
645
- this.getElement().find(`[${tabNameAttr}] ${actionSelector}`).each((index, el) => {
646
- const tab = findTabByName(el.parentNode.getAttribute(tabNameAttr));
647
-
648
- if (!tab || !tab.disabled) {
649
- el.disabled = false;
650
- }
651
- });
652
- }
653
- }) // reacts to tab activate
654
- .on('tabactivate', function onTabActivate(name) {
655
- const tab = findTabByName(name);
653
+ });
654
+ /**
655
+ * @event ready - The component is ready to work
656
+ */
656
657
 
657
- if (tab && !tab.disabled && name !== activeTabName) {
658
- activeTabName = name;
658
+ this.trigger('ready');
659
+ }) // take care of the disable state
660
+ .on('disable', function onButtonDisable() {
661
+ if (this.is('rendered')) {
662
+ disableElement(this.getElement().find("[".concat(tabNameAttr, "] ").concat(actionSelector)));
663
+ }
664
+ }).on('enable', function onButtonEnable() {
665
+ if (this.is('rendered')) {
666
+ this.getElement().find("[".concat(tabNameAttr, "] ").concat(actionSelector)).each(function (index, el) {
667
+ var tab = findTabByName(el.parentNode.getAttribute(tabNameAttr));
659
668
 
660
- if (this.is('rendered')) {
661
- this.getElement().find(tabSelector).removeClass(activeTabCls).filter(`[${tabNameAttr}="${name}"]`).addClass(activeTabCls);
669
+ if (!tab || !tab.disabled) {
670
+ el.disabled = false;
662
671
  }
663
- /**
664
- * @event tabchange - A tab is activated
665
- * @param {String} - name
666
- */
672
+ });
673
+ }
674
+ }) // reacts to tab activate
675
+ .on('tabactivate', function onTabActivate(name) {
676
+ var tab = findTabByName(name);
667
677
 
678
+ if (tab && !tab.disabled && name !== activeTabName) {
679
+ activeTabName = name;
668
680
 
669
- this.trigger('tabchange', name);
670
- }
671
- }) // reacts to tab change
672
- .on('tabchange', function onTabChange(name) {
673
- // auto show the linked panel
674
- if (this.getConfig().showHideTarget) {
675
- this.showTabContent(name);
681
+ if (this.is('rendered')) {
682
+ this.getElement().find(tabSelector).removeClass(activeTabCls).filter("[".concat(tabNameAttr, "=\"").concat(name, "\"]")).addClass(activeTabCls);
676
683
  }
677
684
  /**
678
- * @event tabchange-${name} - The tab is activated
685
+ * @event tabchange - A tab is activated
686
+ * @param {String} - name
679
687
  */
680
688
 
681
689
 
682
- this.trigger(`tabchange-${name}`);
683
- }); // initialize the component with the provided config
684
- // defer the call to allow to listen to the init event
690
+ this.trigger('tabchange', name);
691
+ }
692
+ }) // reacts to tab change
693
+ .on('tabchange', function onTabChange(name) {
694
+ // auto show the linked panel
695
+ if (this.getConfig().showHideTarget) {
696
+ this.showTabContent(name);
697
+ }
698
+ /**
699
+ * @event tabchange-${name} - The tab is activated
700
+ */
701
+
685
702
 
686
- _.defer(() => tabsBarComponent.init(config));
703
+ this.trigger("tabchange-".concat(name));
704
+ }); // initialize the component with the provided config
705
+ // defer the call to allow to listen to the init event
687
706
 
688
- return tabsBarComponent;
689
- }
707
+ _.defer(function () {
708
+ return tabsBarComponent.init(config);
709
+ });
710
+
711
+ return tabsBarComponent;
712
+ }
690
713
 
691
- return tabsFactory;
714
+ return tabsFactory;
692
715
 
693
716
  });