@oat-sa/tao-core-ui 1.58.1 → 1.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actionbar.js +386 -395
- package/dist/adder.js +21 -19
- package/dist/animable/absorbable/absorbable.js +204 -213
- package/dist/animable/absorbable/css/absorb.css +1 -0
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +168 -177
- package/dist/autocomplete/css/autocomplete.css +1 -0
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +68 -66
- package/dist/badge/badge.js +188 -197
- package/dist/badge/css/badge.css +1 -0
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs.js +275 -284
- package/dist/btngrouper.js +5 -5
- package/dist/bulkActionPopup.js +490 -495
- package/dist/button.js +283 -291
- package/dist/cascadingComboBox.js +249 -258
- package/dist/ckeditor/ckConfigurator.js +26 -19
- package/dist/ckeditor/dtdHandler.js +11 -9
- package/dist/class/selector.js +441 -450
- package/dist/component/resizable.js +1 -1
- package/dist/component/windowed.js +285 -294
- package/dist/component.js +419 -428
- package/dist/contextualPopup.js +417 -426
- package/dist/dashboard.js +300 -309
- package/dist/datalist.js +753 -762
- package/dist/datatable/filterStrategy/multiple.js +1 -1
- package/dist/datatable/filterStrategy/single.js +1 -1
- package/dist/datatable.js +1527 -1550
- package/dist/dateRange/dateRange.js +393 -402
- package/dist/datetime/picker.js +665 -672
- package/dist/deleter.js +368 -377
- package/dist/destination/selector.js +286 -295
- package/dist/dialog/alert.js +3 -3
- package/dist/dialog/confirm.js +1 -1
- package/dist/dialog/confirmDelete.js +216 -225
- package/dist/dialog.js +650 -654
- package/dist/disabler.js +8 -8
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
- package/dist/documentViewer/providers/pdfViewer.js +184 -193
- package/dist/documentViewer.js +292 -301
- package/dist/dropdown.js +383 -392
- package/dist/durationer.js +5 -5
- package/dist/dynamicComponent.js +597 -598
- package/dist/feedback.js +356 -362
- package/dist/figure/FigureStateActive.js +117 -108
- package/dist/filesender.js +2 -2
- package/dist/filter.js +230 -239
- package/dist/form/dropdownForm.js +355 -357
- package/dist/form/form.js +919 -690
- package/dist/form/simpleForm.js +1 -1
- package/dist/form/validator/renderer.js +233 -235
- package/dist/form/validator/validator.js +257 -189
- package/dist/form/widget/definitions.js +1 -1
- package/dist/form/widget/providers/checkBox.js +254 -259
- package/dist/form/widget/providers/comboBox.js +187 -192
- package/dist/form/widget/providers/default.js +8 -9
- package/dist/form/widget/providers/hidden.js +170 -179
- package/dist/form/widget/providers/hiddenBox.js +262 -267
- package/dist/form/widget/providers/radioBox.js +216 -225
- package/dist/form/widget/providers/textArea.js +187 -196
- package/dist/form/widget/providers/textBox.js +2 -3
- package/dist/form/widget/widget.js +473 -475
- package/dist/formValidator/formValidator.js +1 -1
- package/dist/formValidator/highlighters/message.js +1 -1
- package/dist/generis/form/form.js +314 -323
- package/dist/generis/validator/validator.js +209 -218
- package/dist/generis/widget/checkBox/checkBox.js +218 -227
- package/dist/generis/widget/comboBox/comboBox.js +179 -188
- package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
- package/dist/generis/widget/textBox/textBox.js +169 -178
- package/dist/generis/widget/widget.js +246 -255
- package/dist/groupedComboBox.js +222 -231
- package/dist/groupvalidator.js +2 -2
- package/dist/highlighter.js +967 -958
- package/dist/image/ImgStateActive/helper.js +7 -5
- package/dist/image/ImgStateActive/initHelper.js +49 -43
- package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
- package/dist/image/ImgStateActive/mediaSizer.js +14 -12
- package/dist/image/ImgStateActive.js +72 -70
- package/dist/incrementer.js +6 -6
- package/dist/inplacer.js +6 -6
- package/dist/itemButtonList/css/item-button-list.css +1 -0
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +439 -435
- package/dist/keyNavigation/navigableDomElement.js +51 -38
- package/dist/keyNavigation/navigator.js +85 -70
- package/dist/listbox.js +460 -469
- package/dist/liststyler.js +8 -8
- package/dist/loadingButton/loadingButton.js +209 -218
- package/dist/lock.js +476 -485
- package/dist/login/login.js +475 -484
- package/dist/maths/calculator/basicCalculator.js +235 -244
- package/dist/maths/calculator/calculatorComponent.js +3 -3
- package/dist/maths/calculator/core/board.js +772 -781
- package/dist/maths/calculator/core/expression.js +476 -485
- package/dist/maths/calculator/core/labels.js +228 -237
- package/dist/maths/calculator/core/tokenizer.js +1 -1
- package/dist/maths/calculator/core/tokens.js +163 -170
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
- package/dist/maths/calculator/scientificCalculator.js +327 -336
- package/dist/mediaEditor/mediaEditorComponent.js +238 -245
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
- package/dist/mediaplayer/players/html5.js +666 -675
- package/dist/mediaplayer/players/youtube.js +419 -424
- package/dist/mediaplayer/support.js +11 -10
- package/dist/mediaplayer/utils/reminder.js +14 -13
- package/dist/mediaplayer/utils/timeObserver.js +10 -11
- package/dist/mediaplayer/youtubeManager.js +164 -145
- package/dist/mediaplayer.js +1565 -1520
- package/dist/mediasizer.js +669 -678
- package/dist/modal.js +10 -17
- package/dist/pageSizeSelector.js +219 -228
- package/dist/pagination/providers/pages.js +280 -289
- package/dist/pagination/providers/simple.js +192 -201
- package/dist/previewer.js +30 -30
- package/dist/progressbar.js +4 -4
- package/dist/report.js +347 -356
- package/dist/resource/filters.js +271 -280
- package/dist/resource/list.js +1264 -1273
- package/dist/resource/selector.js +865 -874
- package/dist/resource/tree.js +1483 -1492
- package/dist/resourcemgr/fileBrowser.js +564 -569
- package/dist/resourcemgr/filePreview.js +16 -16
- package/dist/resourcemgr/fileSelector.js +515 -524
- package/dist/resourcemgr/util/updatePermissions.js +2 -2
- package/dist/resourcemgr.js +306 -315
- package/dist/searchModal/advancedSearch.js +796 -767
- package/dist/searchModal.js +114 -91
- package/dist/switch/switch.js +298 -307
- package/dist/tabs.js +598 -575
- package/dist/taskQueue/status.js +312 -321
- package/dist/taskQueue/table.js +375 -384
- package/dist/taskQueue/taskQueueModel.js +488 -472
- package/dist/taskQueueButton/taskable.js +264 -273
- package/dist/taskQueueButton/treeButton.js +189 -198
- package/dist/themeLoader.js +24 -23
- package/dist/themes.js +1 -1
- package/dist/toggler.js +3 -3
- package/dist/tooltip.js +295 -304
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup.js +311 -320
- package/dist/uploader.js +687 -696
- package/dist/validator/Report.js +1 -1
- package/dist/validator/Validator.js +3 -3
- package/dist/validator/validators.js +9 -9
- package/dist/validator.js +240 -230
- package/dist/waitForMedia.js +1 -1
- package/package.json +3 -3
- package/src/animable/absorbable/css/absorb.css +1 -0
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css +1 -0
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/badge/css/badge.css +1 -0
- package/src/badge/css/badge.css.map +1 -1
- package/src/ckeditor/ckConfigurator.js +4 -0
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/.DS_Store +0 -0
- package/src/css/basic.css +0 -7826
- package/src/css/basic.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
- package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
- package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
- package/src/scss/.DS_Store +0 -0
- package/src/scss/basic.scss +0 -16
- package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
- package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
- package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
- package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
- package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
- package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
- package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
- package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
- package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
- package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
- package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
- package/src/scss/font/tao/tao.eot +0 -0
- package/src/scss/font/tao/tao.svg +0 -235
- package/src/scss/font/tao/tao.ttf +0 -0
- package/src/scss/font/tao/tao.woff +0 -0
- package/src/scss/inc/_base.scss +0 -496
- package/src/scss/inc/_bootstrap.scss +0 -6
- package/src/scss/inc/_buttons.scss +0 -114
- package/src/scss/inc/_colors.scss +0 -88
- package/src/scss/inc/_feedback.scss +0 -150
- package/src/scss/inc/_flex-grid.scss +0 -15
- package/src/scss/inc/_fonts.scss +0 -4
- package/src/scss/inc/_forms.scss +0 -827
- package/src/scss/inc/_functions.scss +0 -283
- package/src/scss/inc/_grid.scss +0 -66
- package/src/scss/inc/_jquery.nouislider.scss +0 -254
- package/src/scss/inc/_normalize.scss +0 -528
- package/src/scss/inc/_report.scss +0 -68
- package/src/scss/inc/_secondary-properties.scss +0 -89
- package/src/scss/inc/_select2.scss +0 -634
- package/src/scss/inc/_toolbars.scss +0 -155
- package/src/scss/inc/_tooltip.scss +0 -312
- package/src/scss/inc/_variables.scss +0 -21
- package/src/scss/inc/base/_highlight.scss +0 -5
- package/src/scss/inc/base/_list-style.scss +0 -59
- package/src/scss/inc/base/_svg.scss +0 -3
- package/src/scss/inc/base/_table.scss +0 -63
- package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
- package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
- package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
- package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
package/dist/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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
55
|
-
var
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
else {
|
|
164
|
-
|
|
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
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
*
|
|
221
|
-
* @
|
|
222
|
-
* @
|
|
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
|
-
|
|
352
|
+
var findTabByName = function findTabByName(name) {
|
|
353
|
+
return tabs.find(function (tab) {
|
|
354
|
+
return tab.name === name;
|
|
355
|
+
});
|
|
356
|
+
};
|
|
234
357
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* @type {String}
|
|
255
|
-
*/
|
|
368
|
+
if (!tab) {
|
|
369
|
+
throw new TypeError("No tab exists with the name: ".concat(name));
|
|
370
|
+
}
|
|
256
371
|
|
|
257
|
-
|
|
372
|
+
return tab;
|
|
373
|
+
};
|
|
258
374
|
/**
|
|
259
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
397
|
+
var tabsApi = {
|
|
334
398
|
/**
|
|
335
|
-
*
|
|
336
|
-
* @param {
|
|
337
|
-
* @returns {
|
|
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
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
351
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
361
|
-
* @
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
*
|
|
378
|
-
* @
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
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
|
-
|
|
399
|
-
|
|
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
|
-
|
|
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
|
-
|
|
410
|
-
}
|
|
518
|
+
if (!tab.disabled) {
|
|
411
519
|
/**
|
|
412
|
-
* @event
|
|
413
|
-
* @param {
|
|
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
|
-
|
|
418
|
-
|
|
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
|
-
*
|
|
423
|
-
* @
|
|
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
|
-
|
|
439
|
-
|
|
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
|
-
*
|
|
447
|
-
* @
|
|
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
|
-
|
|
464
|
-
|
|
573
|
+
this.trigger('tabdisable', name);
|
|
574
|
+
},
|
|
465
575
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
489
|
-
*
|
|
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
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
-
|
|
525
|
-
|
|
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
|
-
*
|
|
539
|
-
* @param {
|
|
540
|
-
* @returns {tabsBarComponent} instance
|
|
541
|
-
* @throws {TypeError} on invalid name param
|
|
542
|
-
* @fires tabdisable
|
|
622
|
+
* @event error
|
|
623
|
+
* @param {Error} err
|
|
543
624
|
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
-
*
|
|
562
|
-
*
|
|
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
|
-
|
|
568
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
651
|
+
_this2.trigger('error', err);
|
|
607
652
|
}
|
|
608
|
-
})
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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
|
-
|
|
658
|
-
|
|
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 (
|
|
661
|
-
|
|
669
|
+
if (!tab || !tab.disabled) {
|
|
670
|
+
el.disabled = false;
|
|
662
671
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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
|
-
|
|
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
|
|
685
|
+
* @event tabchange - A tab is activated
|
|
686
|
+
* @param {String} - name
|
|
679
687
|
*/
|
|
680
688
|
|
|
681
689
|
|
|
682
|
-
this.trigger(
|
|
683
|
-
}
|
|
684
|
-
|
|
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
|
-
|
|
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
|
-
|
|
689
|
-
|
|
707
|
+
_.defer(function () {
|
|
708
|
+
return tabsBarComponent.init(config);
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
return tabsBarComponent;
|
|
712
|
+
}
|
|
690
713
|
|
|
691
|
-
|
|
714
|
+
return tabsFactory;
|
|
692
715
|
|
|
693
716
|
});
|