@oat-sa/tao-core-ui 1.58.1 → 1.58.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/actionbar.js +386 -395
  2. package/dist/adder.js +21 -19
  3. package/dist/animable/absorbable/absorbable.js +204 -213
  4. package/dist/animable/absorbable/css/absorb.css +1 -0
  5. package/dist/animable/absorbable/css/absorb.css.map +1 -1
  6. package/dist/animable/pulsable/pulsable.js +168 -177
  7. package/dist/autocomplete/css/autocomplete.css +1 -0
  8. package/dist/autocomplete/css/autocomplete.css.map +1 -1
  9. package/dist/autocomplete.js +68 -66
  10. package/dist/badge/badge.js +188 -197
  11. package/dist/badge/css/badge.css +1 -0
  12. package/dist/badge/css/badge.css.map +1 -1
  13. package/dist/breadcrumbs.js +275 -284
  14. package/dist/btngrouper.js +5 -5
  15. package/dist/bulkActionPopup.js +490 -495
  16. package/dist/button.js +283 -291
  17. package/dist/cascadingComboBox.js +249 -258
  18. package/dist/ckeditor/ckConfigurator.js +26 -19
  19. package/dist/ckeditor/dtdHandler.js +11 -9
  20. package/dist/class/selector.js +441 -450
  21. package/dist/component/resizable.js +1 -1
  22. package/dist/component/windowed.js +285 -294
  23. package/dist/component.js +419 -428
  24. package/dist/contextualPopup.js +417 -426
  25. package/dist/dashboard.js +300 -309
  26. package/dist/datalist.js +753 -762
  27. package/dist/datatable/filterStrategy/multiple.js +1 -1
  28. package/dist/datatable/filterStrategy/single.js +1 -1
  29. package/dist/datatable.js +1527 -1550
  30. package/dist/dateRange/dateRange.js +393 -402
  31. package/dist/datetime/picker.js +665 -672
  32. package/dist/deleter.js +368 -377
  33. package/dist/destination/selector.js +286 -295
  34. package/dist/dialog/alert.js +3 -3
  35. package/dist/dialog/confirm.js +1 -1
  36. package/dist/dialog/confirmDelete.js +216 -225
  37. package/dist/dialog.js +650 -654
  38. package/dist/disabler.js +8 -8
  39. package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
  40. package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
  41. package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
  42. package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
  43. package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
  44. package/dist/documentViewer/providers/pdfViewer.js +184 -193
  45. package/dist/documentViewer.js +292 -301
  46. package/dist/dropdown.js +383 -392
  47. package/dist/durationer.js +5 -5
  48. package/dist/dynamicComponent.js +597 -598
  49. package/dist/feedback.js +356 -362
  50. package/dist/figure/FigureStateActive.js +117 -108
  51. package/dist/filesender.js +2 -2
  52. package/dist/filter.js +230 -239
  53. package/dist/form/dropdownForm.js +355 -357
  54. package/dist/form/form.js +919 -690
  55. package/dist/form/simpleForm.js +1 -1
  56. package/dist/form/validator/renderer.js +233 -235
  57. package/dist/form/validator/validator.js +257 -189
  58. package/dist/form/widget/definitions.js +1 -1
  59. package/dist/form/widget/providers/checkBox.js +254 -259
  60. package/dist/form/widget/providers/comboBox.js +187 -192
  61. package/dist/form/widget/providers/default.js +8 -9
  62. package/dist/form/widget/providers/hidden.js +170 -179
  63. package/dist/form/widget/providers/hiddenBox.js +262 -267
  64. package/dist/form/widget/providers/radioBox.js +216 -225
  65. package/dist/form/widget/providers/textArea.js +187 -196
  66. package/dist/form/widget/providers/textBox.js +2 -3
  67. package/dist/form/widget/widget.js +473 -475
  68. package/dist/formValidator/formValidator.js +1 -1
  69. package/dist/formValidator/highlighters/message.js +1 -1
  70. package/dist/generis/form/form.js +314 -323
  71. package/dist/generis/validator/validator.js +209 -218
  72. package/dist/generis/widget/checkBox/checkBox.js +218 -227
  73. package/dist/generis/widget/comboBox/comboBox.js +179 -188
  74. package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
  75. package/dist/generis/widget/textBox/textBox.js +169 -178
  76. package/dist/generis/widget/widget.js +246 -255
  77. package/dist/groupedComboBox.js +222 -231
  78. package/dist/groupvalidator.js +2 -2
  79. package/dist/highlighter.js +967 -958
  80. package/dist/image/ImgStateActive/helper.js +7 -5
  81. package/dist/image/ImgStateActive/initHelper.js +49 -43
  82. package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
  83. package/dist/image/ImgStateActive/mediaSizer.js +14 -12
  84. package/dist/image/ImgStateActive.js +72 -70
  85. package/dist/incrementer.js +6 -6
  86. package/dist/inplacer.js +6 -6
  87. package/dist/itemButtonList/css/item-button-list.css +1 -0
  88. package/dist/itemButtonList/css/item-button-list.css.map +1 -1
  89. package/dist/itemButtonList.js +439 -435
  90. package/dist/keyNavigation/navigableDomElement.js +51 -38
  91. package/dist/keyNavigation/navigator.js +85 -70
  92. package/dist/listbox.js +460 -469
  93. package/dist/liststyler.js +8 -8
  94. package/dist/loadingButton/loadingButton.js +209 -218
  95. package/dist/lock.js +476 -485
  96. package/dist/login/login.js +475 -484
  97. package/dist/maths/calculator/basicCalculator.js +235 -244
  98. package/dist/maths/calculator/calculatorComponent.js +3 -3
  99. package/dist/maths/calculator/core/board.js +772 -781
  100. package/dist/maths/calculator/core/expression.js +476 -485
  101. package/dist/maths/calculator/core/labels.js +228 -237
  102. package/dist/maths/calculator/core/tokenizer.js +1 -1
  103. package/dist/maths/calculator/core/tokens.js +163 -170
  104. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
  105. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
  106. package/dist/maths/calculator/scientificCalculator.js +327 -336
  107. package/dist/mediaEditor/mediaEditorComponent.js +238 -245
  108. package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
  109. package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
  110. package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
  111. package/dist/mediaplayer/players/html5.js +666 -675
  112. package/dist/mediaplayer/players/youtube.js +419 -424
  113. package/dist/mediaplayer/support.js +11 -10
  114. package/dist/mediaplayer/utils/reminder.js +14 -13
  115. package/dist/mediaplayer/utils/timeObserver.js +10 -11
  116. package/dist/mediaplayer/youtubeManager.js +164 -145
  117. package/dist/mediaplayer.js +1565 -1520
  118. package/dist/mediasizer.js +669 -678
  119. package/dist/modal.js +10 -17
  120. package/dist/pageSizeSelector.js +219 -228
  121. package/dist/pagination/providers/pages.js +280 -289
  122. package/dist/pagination/providers/simple.js +192 -201
  123. package/dist/previewer.js +30 -30
  124. package/dist/progressbar.js +4 -4
  125. package/dist/report.js +347 -356
  126. package/dist/resource/filters.js +271 -280
  127. package/dist/resource/list.js +1264 -1273
  128. package/dist/resource/selector.js +865 -874
  129. package/dist/resource/tree.js +1483 -1492
  130. package/dist/resourcemgr/fileBrowser.js +564 -569
  131. package/dist/resourcemgr/filePreview.js +16 -16
  132. package/dist/resourcemgr/fileSelector.js +515 -524
  133. package/dist/resourcemgr/util/updatePermissions.js +2 -2
  134. package/dist/resourcemgr.js +306 -315
  135. package/dist/searchModal/advancedSearch.js +796 -767
  136. package/dist/searchModal.js +114 -91
  137. package/dist/switch/switch.js +298 -307
  138. package/dist/tabs.js +598 -575
  139. package/dist/taskQueue/status.js +312 -321
  140. package/dist/taskQueue/table.js +375 -384
  141. package/dist/taskQueue/taskQueueModel.js +488 -472
  142. package/dist/taskQueueButton/taskable.js +264 -273
  143. package/dist/taskQueueButton/treeButton.js +189 -198
  144. package/dist/themeLoader.js +24 -23
  145. package/dist/themes.js +1 -1
  146. package/dist/toggler.js +3 -3
  147. package/dist/tooltip.js +295 -304
  148. package/dist/transformer.js +2 -2
  149. package/dist/tristateCheckboxGroup.js +311 -320
  150. package/dist/uploader.js +687 -696
  151. package/dist/validator/Report.js +1 -1
  152. package/dist/validator/Validator.js +3 -3
  153. package/dist/validator/validators.js +9 -9
  154. package/dist/validator.js +240 -230
  155. package/dist/waitForMedia.js +1 -1
  156. package/package.json +3 -3
  157. package/src/animable/absorbable/css/absorb.css +1 -0
  158. package/src/animable/absorbable/css/absorb.css.map +1 -1
  159. package/src/autocomplete/css/autocomplete.css +1 -0
  160. package/src/autocomplete/css/autocomplete.css.map +1 -1
  161. package/src/badge/css/badge.css +1 -0
  162. package/src/badge/css/badge.css.map +1 -1
  163. package/src/ckeditor/ckConfigurator.js +4 -0
  164. package/src/itemButtonList/css/item-button-list.css +1 -0
  165. package/src/itemButtonList/css/item-button-list.css.map +1 -1
  166. package/src/.DS_Store +0 -0
  167. package/src/css/basic.css +0 -7826
  168. package/src/css/basic.css.map +0 -1
  169. package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
  170. package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
  171. package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
  172. package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
  173. package/src/scss/.DS_Store +0 -0
  174. package/src/scss/basic.scss +0 -16
  175. package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
  176. package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
  177. package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
  178. package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
  179. package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
  180. package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
  181. package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
  182. package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
  183. package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
  184. package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
  185. package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
  186. package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
  187. package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
  188. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
  189. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
  190. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
  191. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
  192. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
  193. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
  194. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
  195. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
  196. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
  197. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
  198. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
  199. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
  200. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
  201. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
  202. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
  203. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
  204. package/src/scss/font/tao/tao.eot +0 -0
  205. package/src/scss/font/tao/tao.svg +0 -235
  206. package/src/scss/font/tao/tao.ttf +0 -0
  207. package/src/scss/font/tao/tao.woff +0 -0
  208. package/src/scss/inc/_base.scss +0 -496
  209. package/src/scss/inc/_bootstrap.scss +0 -6
  210. package/src/scss/inc/_buttons.scss +0 -114
  211. package/src/scss/inc/_colors.scss +0 -88
  212. package/src/scss/inc/_feedback.scss +0 -150
  213. package/src/scss/inc/_flex-grid.scss +0 -15
  214. package/src/scss/inc/_fonts.scss +0 -4
  215. package/src/scss/inc/_forms.scss +0 -827
  216. package/src/scss/inc/_functions.scss +0 -283
  217. package/src/scss/inc/_grid.scss +0 -66
  218. package/src/scss/inc/_jquery.nouislider.scss +0 -254
  219. package/src/scss/inc/_normalize.scss +0 -528
  220. package/src/scss/inc/_report.scss +0 -68
  221. package/src/scss/inc/_secondary-properties.scss +0 -89
  222. package/src/scss/inc/_select2.scss +0 -634
  223. package/src/scss/inc/_toolbars.scss +0 -155
  224. package/src/scss/inc/_tooltip.scss +0 -312
  225. package/src/scss/inc/_variables.scss +0 -21
  226. package/src/scss/inc/base/_highlight.scss +0 -5
  227. package/src/scss/inc/base/_list-style.scss +0 -59
  228. package/src/scss/inc/base/_svg.scss +0 -3
  229. package/src/scss/inc/base/_table.scss +0 -63
  230. package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
  231. package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
  232. package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
  233. package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
@@ -1,660 +1,655 @@
1
1
  define(['jquery', 'lodash', 'core/request', 'ui/pagination', 'handlebars', 'i18n', 'lib/dompurify/purify'], function ($$1, _, request, paginationComponent, Handlebars, __, DOMPurify) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- request = request && Object.prototype.hasOwnProperty.call(request, 'default') ? request['default'] : request;
6
- paginationComponent = paginationComponent && Object.prototype.hasOwnProperty.call(paginationComponent, 'default') ? paginationComponent['default'] : paginationComponent;
7
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
8
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
9
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
10
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ request = request && Object.prototype.hasOwnProperty.call(request, 'default') ? request['default'] : request;
6
+ paginationComponent = paginationComponent && Object.prototype.hasOwnProperty.call(paginationComponent, 'default') ? paginationComponent['default'] : paginationComponent;
7
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
8
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
9
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
10
+
11
+ function _typeof(obj) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
15
+ return typeof obj;
16
+ } : function (obj) {
17
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18
+ }, _typeof(obj);
19
+ }
20
+
21
+ function Helpers0 (hb) {
22
+ //register a i18n helper
23
+ hb.registerHelper('__', function (key) {
24
+ return __(key);
25
+ });
11
26
  /**
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * as published by the Free Software Foundation; under version 2
15
- * of the License (non-upgradable).
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
- *
26
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
27
- *
27
+ * Register dompurify helper
28
28
  *
29
+ * https://github.com/cure53/DOMPurify
30
+ * with config SAFE_FOR_TEMPLATES: true
31
+ * to make output safe for template systems
29
32
  */
30
- function Helpers0 (hb) {
31
- //register a i18n helper
32
- hb.registerHelper('__', function (key) {
33
- return __(key);
34
- });
35
- /**
36
- * Register dompurify helper
37
- *
38
- * https://github.com/cure53/DOMPurify
39
- * with config SAFE_FOR_TEMPLATES: true
40
- * to make output safe for template systems
41
- */
42
-
43
- hb.registerHelper('dompurify', function (context) {
44
- return DOMPurify.sanitize(context);
45
- });
46
- /**
47
- * Register join helper
48
- *
49
- * Example :
50
- * var values = {a:v1, b:v2, c:v3};
51
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
52
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
53
- */
54
-
55
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
56
- var fragments = [];
57
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
58
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
59
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
60
-
61
- _.forIn(arr, function (value, key) {
62
- var fragment = '';
63
-
64
- if (value !== null || value !== undefined) {
65
- if (typeof value === 'boolean') {
66
- value = value ? 'true' : 'false';
67
- } else if (typeof value === 'object') {
68
- value = _.values(value).join(' ');
69
- }
70
- } else {
71
- value = '';
72
- }
73
33
 
74
- if (keyValueGlue !== undefined) {
75
- fragment += key + keyValueGlue;
76
- }
34
+ hb.registerHelper('dompurify', function (context) {
35
+ return DOMPurify.sanitize(context);
36
+ });
37
+ /**
38
+ * Register join helper
39
+ *
40
+ * Example :
41
+ * var values = {a:v1, b:v2, c:v3};
42
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
43
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
44
+ */
77
45
 
78
- fragment += wrapper + value + wrapper;
79
- fragments.push(fragment);
80
- });
46
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
47
+ var fragments = [];
48
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
49
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
50
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
81
51
 
82
- return fragments.join(fragmentGlue);
83
- }); //register a classic "for loop" helper
84
- //it also adds a local variable "i" as the index in each iteration loop
52
+ _.forIn(arr, function (value, key) {
53
+ var fragment = '';
85
54
 
86
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
87
- var ret = '';
88
- startIndex = parseInt(startIndex);
89
- stopIndex = parseInt(stopIndex);
90
- increment = parseInt(increment);
55
+ if (value !== null || value !== undefined) {
56
+ if (typeof value === 'boolean') {
57
+ value = value ? 'true' : 'false';
58
+ } else if (_typeof(value) === 'object') {
59
+ value = _.values(value).join(' ');
60
+ }
61
+ } else {
62
+ value = '';
63
+ }
91
64
 
92
- for (var i = startIndex; i < stopIndex; i += increment) {
93
- ret += options.fn(_.extend({}, this, {
94
- i: i
95
- }));
65
+ if (keyValueGlue !== undefined) {
66
+ fragment += key + keyValueGlue;
96
67
  }
97
68
 
98
- return ret;
69
+ fragment += wrapper + value + wrapper;
70
+ fragments.push(fragment);
99
71
  });
100
- hb.registerHelper('equal', function (var1, var2, options) {
101
- if (var1 == var2) {
102
- return options.fn(this);
103
- } else {
104
- return options.inverse(this);
105
- }
106
- }); // register a "get property" helper
107
- // it gets the named property from the provided context
108
72
 
109
- hb.registerHelper('property', function (name, context) {
110
- return context[name] || '';
111
- }); // register an 'includes' helper
112
- // it checks if value is in array
73
+ return fragments.join(fragmentGlue);
74
+ }); //register a classic "for loop" helper
75
+ //it also adds a local variable "i" as the index in each iteration loop
113
76
 
114
- hb.registerHelper('includes', function (haystack, needle, options) {
115
- if (_.contains(haystack, needle)) {
116
- return options.fn(this);
117
- }
118
- });
119
- }
77
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
78
+ var ret = '';
79
+ startIndex = parseInt(startIndex);
80
+ stopIndex = parseInt(stopIndex);
81
+ increment = parseInt(increment);
120
82
 
121
- if (!Helpers0.__initialized) {
122
- Helpers0(Handlebars);
123
- Helpers0.__initialized = true;
124
- }
125
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
126
- this.compilerInfo = [4,'>= 1.0.0'];
127
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
128
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
129
-
130
- function program1(depth0,data) {
131
-
132
- var buffer = "", stack1, helper;
133
- buffer += "\n <li class=\"root\">\n <a\n class=\"root-folder active\"\n href=\"#\"\n data-path=\"";
134
- if (helper = helpers.path) { stack1 = helper.call(depth0, {hash:{},data:data}); }
135
- else { helper = (depth0 && depth0.path); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
136
- buffer += escapeExpression(stack1)
137
- + "\"\n data-display=\"";
138
- if (helper = helpers.relPath) { stack1 = helper.call(depth0, {hash:{},data:data}); }
139
- else { helper = (depth0 && depth0.relPath); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
140
- buffer += escapeExpression(stack1)
141
- + "\"\n data-children-limit=\"";
142
- if (helper = helpers.childrenLimit) { stack1 = helper.call(depth0, {hash:{},data:data}); }
143
- else { helper = (depth0 && depth0.childrenLimit); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
144
- buffer += escapeExpression(stack1)
145
- + "\">\n ";
146
- if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
147
- else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
148
- buffer += escapeExpression(stack1)
149
- + "\n </a>\n <ul></ul>\n </li>\n";
150
- return buffer;
83
+ for (var i = startIndex; i < stopIndex; i += increment) {
84
+ ret += options.fn(_.extend({}, this, {
85
+ i: i
86
+ }));
151
87
  }
152
88
 
153
- stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.permissions)),stack1 == null || stack1 === false ? stack1 : stack1.read), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
154
- if(stack1 || stack1 === 0) { buffer += stack1; }
155
- buffer += "\n";
156
- return buffer;
157
- });
158
- function rootFolderTpl(data, options, asString) {
159
- var html = Template(data, options);
160
- return (asString || true) ? html : $(html);
161
- }
162
-
163
- if (!Helpers0.__initialized) {
164
- Helpers0(Handlebars);
165
- Helpers0.__initialized = true;
166
- }
167
- var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
168
- this.compilerInfo = [4,'>= 1.0.0'];
169
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
170
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
171
-
172
- function program1(depth0,data) {
173
-
174
- var buffer = "", stack1, helper;
175
- buffer += "\n <li>\n <a\n data-path=\"";
176
- if (helper = helpers.path) { stack1 = helper.call(depth0, {hash:{},data:data}); }
177
- else { helper = (depth0 && depth0.path); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
178
- buffer += escapeExpression(stack1)
179
- + "\"\n data-display=\"";
180
- if (helper = helpers.relPath) { stack1 = helper.call(depth0, {hash:{},data:data}); }
181
- else { helper = (depth0 && depth0.relPath); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
182
- buffer += escapeExpression(stack1)
183
- + "\"\n data-children-limit=\"";
184
- if (helper = helpers.childrenLimit) { stack1 = helper.call(depth0, {hash:{},data:data}); }
185
- else { helper = (depth0 && depth0.childrenLimit); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
186
- buffer += escapeExpression(stack1)
187
- + "\"\n href=\"#\">\n ";
188
- if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
189
- else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
190
- buffer += escapeExpression(stack1)
191
- + "\n </a>\n </li>\n";
192
- return buffer;
89
+ return ret;
90
+ });
91
+ hb.registerHelper('equal', function (var1, var2, options) {
92
+ if (var1 == var2) {
93
+ return options.fn(this);
94
+ } else {
95
+ return options.inverse(this);
193
96
  }
97
+ }); // register a "get property" helper
98
+ // it gets the named property from the provided context
194
99
 
195
- stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.permissions)),stack1 == null || stack1 === false ? stack1 : stack1.read), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
196
- if(stack1 || stack1 === 0) { buffer += stack1; }
197
- buffer += "\n";
198
- return buffer;
199
- });
200
- function folderTpl(data, options, asString) {
201
- var html = Template$1(data, options);
202
- return (asString || true) ? html : $(html);
100
+ hb.registerHelper('property', function (name, context) {
101
+ return context[name] || '';
102
+ }); // register an 'includes' helper
103
+ // it checks if value is in array
104
+
105
+ hb.registerHelper('includes', function (haystack, needle, options) {
106
+ if (_.contains(haystack, needle)) {
107
+ return options.fn(this);
108
+ }
109
+ });
110
+ }
111
+
112
+ if (!Helpers0.__initialized) {
113
+ Helpers0(Handlebars);
114
+ Helpers0.__initialized = true;
115
+ }
116
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
117
+ this.compilerInfo = [4,'>= 1.0.0'];
118
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
119
+ var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
120
+
121
+ function program1(depth0,data) {
122
+
123
+ var buffer = "", stack1, helper;
124
+ buffer += "\n <li class=\"root\">\n <a\n class=\"root-folder active\"\n href=\"#\"\n data-path=\"";
125
+ if (helper = helpers.path) { stack1 = helper.call(depth0, {hash:{},data:data}); }
126
+ else { helper = (depth0 && depth0.path); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
127
+ buffer += escapeExpression(stack1)
128
+ + "\"\n data-display=\"";
129
+ if (helper = helpers.relPath) { stack1 = helper.call(depth0, {hash:{},data:data}); }
130
+ else { helper = (depth0 && depth0.relPath); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
131
+ buffer += escapeExpression(stack1)
132
+ + "\"\n data-children-limit=\"";
133
+ if (helper = helpers.childrenLimit) { stack1 = helper.call(depth0, {hash:{},data:data}); }
134
+ else { helper = (depth0 && depth0.childrenLimit); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
135
+ buffer += escapeExpression(stack1)
136
+ + "\">\n ";
137
+ if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
138
+ else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
139
+ buffer += escapeExpression(stack1)
140
+ + "\n </a>\n <ul></ul>\n </li>\n";
141
+ return buffer;
203
142
  }
204
143
 
205
- /**
206
- * Update the permissions in HTML Tree
207
- * @param {Object} item - the tree item
208
- * @return {Object} - item with permissions
209
- */
210
- function updatePermissions(item) {
211
- const isAssets = (item.uri || item.path || '').includes('mediamanager');
212
- let permissions = {
213
- read: true,
214
- write: true,
215
- preview: true,
216
- download: true,
217
- upload: true,
218
- delete: true
219
- };
144
+ stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.permissions)),stack1 == null || stack1 === false ? stack1 : stack1.read), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
145
+ if(stack1 || stack1 === 0) { buffer += stack1; }
146
+ buffer += "\n";
147
+ return buffer;
148
+ });
149
+ function rootFolderTpl(data, options, asString) {
150
+ var html = Template(data, options);
151
+ return (asString || true) ? html : $(html);
152
+ }
153
+
154
+ if (!Helpers0.__initialized) {
155
+ Helpers0(Handlebars);
156
+ Helpers0.__initialized = true;
157
+ }
158
+ var Template$1 = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
159
+ this.compilerInfo = [4,'>= 1.0.0'];
160
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
161
+ var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
162
+
163
+ function program1(depth0,data) {
164
+
165
+ var buffer = "", stack1, helper;
166
+ buffer += "\n <li>\n <a\n data-path=\"";
167
+ if (helper = helpers.path) { stack1 = helper.call(depth0, {hash:{},data:data}); }
168
+ else { helper = (depth0 && depth0.path); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
169
+ buffer += escapeExpression(stack1)
170
+ + "\"\n data-display=\"";
171
+ if (helper = helpers.relPath) { stack1 = helper.call(depth0, {hash:{},data:data}); }
172
+ else { helper = (depth0 && depth0.relPath); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
173
+ buffer += escapeExpression(stack1)
174
+ + "\"\n data-children-limit=\"";
175
+ if (helper = helpers.childrenLimit) { stack1 = helper.call(depth0, {hash:{},data:data}); }
176
+ else { helper = (depth0 && depth0.childrenLimit); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
177
+ buffer += escapeExpression(stack1)
178
+ + "\"\n href=\"#\">\n ";
179
+ if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); }
180
+ else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
181
+ buffer += escapeExpression(stack1)
182
+ + "\n </a>\n </li>\n";
183
+ return buffer;
184
+ }
220
185
 
221
- if (item.permissions) {
222
- if (!item.permissions.includes('READ')) {
223
- permissions.read = false;
224
- }
186
+ stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.permissions)),stack1 == null || stack1 === false ? stack1 : stack1.read), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
187
+ if(stack1 || stack1 === 0) { buffer += stack1; }
188
+ buffer += "\n";
189
+ return buffer;
190
+ });
191
+ function folderTpl(data, options, asString) {
192
+ var html = Template$1(data, options);
193
+ return (asString || true) ? html : $(html);
194
+ }
195
+
196
+ /**
197
+ * Update the permissions in HTML Tree
198
+ * @param {Object} item - the tree item
199
+ * @return {Object} - item with permissions
200
+ */
201
+ function updatePermissions(item) {
202
+ var isAssets = (item.uri || item.path || '').includes('mediamanager');
203
+ var permissions = {
204
+ read: true,
205
+ write: true,
206
+ preview: true,
207
+ download: true,
208
+ upload: true,
209
+ delete: true
210
+ };
211
+
212
+ if (item.permissions) {
213
+ if (!item.permissions.includes('READ')) {
214
+ permissions.read = false;
215
+ }
225
216
 
226
- if (!item.permissions.includes('WRITE')) {
227
- permissions.write = false;
228
- } // Atomic permissions for Assets
217
+ if (!item.permissions.includes('WRITE')) {
218
+ permissions.write = false;
219
+ } // Atomic permissions for Assets
229
220
 
230
221
 
231
- if (isAssets) {
232
- if (!item.permissions.includes('PREVIEW')) {
233
- permissions.preview = false;
234
- }
222
+ if (isAssets) {
223
+ if (!item.permissions.includes('PREVIEW')) {
224
+ permissions.preview = false;
225
+ }
235
226
 
236
- if (!item.permissions.includes('DOWNLOAD')) {
237
- permissions.download = false;
238
- }
227
+ if (!item.permissions.includes('DOWNLOAD')) {
228
+ permissions.download = false;
229
+ }
239
230
 
240
- if (!item.permissions.includes('UPLOAD')) {
241
- permissions.upload = false;
242
- }
231
+ if (!item.permissions.includes('UPLOAD')) {
232
+ permissions.upload = false;
233
+ }
243
234
 
244
- if (!item.permissions.includes('DELETE')) {
245
- permissions.delete = false;
246
- } // Generic permissions for item gallery media
235
+ if (!item.permissions.includes('DELETE')) {
236
+ permissions.delete = false;
237
+ } // Generic permissions for item gallery media
247
238
 
248
- } else {
249
- if (!permissions.read) {
250
- permissions.preview = false;
251
- permissions.download = false;
252
- }
239
+ } else {
240
+ if (!permissions.read) {
241
+ permissions.preview = false;
242
+ permissions.download = false;
243
+ }
253
244
 
254
- if (!permissions.write) {
255
- permissions.delete = false;
256
- permissions.upload = false;
257
- }
245
+ if (!permissions.write) {
246
+ permissions.delete = false;
247
+ permissions.upload = false;
258
248
  }
259
249
  }
260
-
261
- item.permissions = permissions;
262
- return item;
263
250
  }
264
251
 
265
- /**
266
- * This program is free software; you can redistribute it and/or
267
- * modify it under the terms of the GNU General Public License
268
- * as published by the Free Software Foundation; under version 2
269
- * of the License (non-upgradable).
270
- *
271
- * This program is distributed in the hope that it will be useful,
272
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
273
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
274
- * GNU General Public License for more details.
275
- *
276
- * You should have received a copy of the GNU General Public License
277
- * along with this program; if not, write to the Free Software
278
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
279
- *
280
- * Copyright (c) 2018-2020 (original work) Open Assessment Technologies SA;
281
- */
282
- const ns = 'resourcemgr';
283
- function fileBrowser (options) {
284
- const root = options.root || 'local';
285
- const rootPath = options.path || '/';
286
- const $container = options.$target;
287
- const $fileBrowser = $$1('.file-browser .file-browser-wrapper', $container);
288
- const $divContainer = $$1(`.${root}`, $fileBrowser);
289
- const $folderContainer = $$1('.folders', $divContainer);
290
- const fileTree = {}; // for pagination
291
-
292
- let selectedClass = {
293
- path: rootPath,
294
- childrenLimit: 10,
295
- total: 0,
296
- page: 1
297
- }; //load the content of the ROOT
252
+ item.permissions = permissions;
253
+ return item;
254
+ }
255
+
256
+ /**
257
+ * This program is free software; you can redistribute it and/or
258
+ * modify it under the terms of the GNU General Public License
259
+ * as published by the Free Software Foundation; under version 2
260
+ * of the License (non-upgradable).
261
+ *
262
+ * This program is distributed in the hope that it will be useful,
263
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
264
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
265
+ * GNU General Public License for more details.
266
+ *
267
+ * You should have received a copy of the GNU General Public License
268
+ * along with this program; if not, write to the Free Software
269
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
270
+ *
271
+ * Copyright (c) 2018-2020 (original work) Open Assessment Technologies SA;
272
+ */
273
+ var ns = 'resourcemgr';
274
+ function fileBrowser (options) {
275
+ var root = options.root || 'local';
276
+ var rootPath = options.path || '/';
277
+ var $container = options.$target;
278
+ var $fileBrowser = $$1('.file-browser .file-browser-wrapper', $container);
279
+ var $divContainer = $$1(".".concat(root), $fileBrowser);
280
+ var $folderContainer = $$1('.folders', $divContainer);
281
+ var fileTree = {}; // for pagination
282
+
283
+ var selectedClass = {
284
+ path: rootPath,
285
+ childrenLimit: 10,
286
+ total: 0,
287
+ page: 1
288
+ }; //load the content of the ROOT
289
+
290
+ getFolderContent(fileTree, rootPath, function (content) {
291
+ //create the tree node for the ROOT folder by default once the initial content loaded
292
+ $folderContainer.append(rootFolderTpl(content));
293
+ var $rootNode = $$1('.root-folder', $folderContainer); //create an inner list and append found elements
294
+
295
+ var $innerList = $$1('.root ul', $folderContainer);
296
+
297
+ if (content.children) {
298
+ $rootNode.addClass('opened');
299
+ }
298
300
 
299
- getFolderContent(fileTree, rootPath, function (content) {
300
- //create the tree node for the ROOT folder by default once the initial content loaded
301
- $folderContainer.append(rootFolderTpl(content));
302
- const $rootNode = $$1('.root-folder', $folderContainer); //create an inner list and append found elements
301
+ updateFolders(content, $innerList);
303
302
 
304
- const $innerList = $$1('.root ul', $folderContainer);
303
+ if (content.permissions.read && !options.hasAlreadySelected) {
304
+ $$1('.file-browser').find('li.active').removeClass('active');
305
+ updateSelectedClass(content.path, content.total, content.childrenLimit);
306
+ $container.trigger('folderselect.'.concat(ns), [content.label, getPage(content.children), content.path, content]);
307
+ renderPagination();
305
308
 
306
- if (content.children) {
307
- $rootNode.addClass('opened');
309
+ if (root !== 'local') {
310
+ options.hasAlreadySelected = true;
308
311
  }
312
+ }
313
+ }); // by clicking on the tree (using a live binding because content is not complete yet)
314
+
315
+ $divContainer.off('click', '.folders a').on('click', '.folders a', function (e) {
316
+ e.preventDefault();
317
+ var $selected = $$1(this);
318
+ var $folders = $$1('.folders li', $fileBrowser);
319
+ var fullPath = $selected.data('path');
320
+ var subTree = getByPath(fileTree, fullPath); //get the folder content
321
+
322
+ getFolderContent(subTree, fullPath, function (content) {
323
+ if (content) {
324
+ //either create the inner list of the content is new or just show it
325
+ var $innerList = $selected.siblings('ul');
326
+
327
+ if (!$innerList.length && content.children && _.find(content.children, 'path') && !content.empty) {
328
+ $innerList = $$1('<ul></ul>').insertAfter($selected);
329
+ updateFolders(content, $innerList);
330
+ $selected.addClass('opened');
331
+ } else if ($innerList.length) {
332
+ if ($innerList.css('display') === 'none') {
333
+ $innerList.show();
334
+ $selected.addClass('opened');
335
+ } else if ($selected.parent('li').hasClass('active')) {
336
+ $innerList.hide();
337
+ $selected.removeClass('opened');
338
+ }
339
+ } //toggle active element
309
340
 
310
- updateFolders(content, $innerList);
311
341
 
312
- if (content.permissions.read && !options.hasAlreadySelected) {
313
- $$1('.file-browser').find('li.active').removeClass('active');
314
- updateSelectedClass(content.path, content.total, content.childrenLimit);
315
- $container.trigger('folderselect.'.concat(ns), [content.label, getPage(content.children), content.path, content]);
316
- renderPagination();
342
+ $folders.removeClass('active');
343
+ $selected.parent('li').addClass('active'); //internal event to set the file-selector content
317
344
 
318
- if (root !== 'local') {
319
- options.hasAlreadySelected = true;
320
- }
345
+ updateSelectedClass(fullPath, subTree.total, $selected.data('children-limit'));
346
+ $container.trigger("folderselect.".concat(ns), [content.label, getPage(content.children), content.path, content]);
347
+ renderPagination();
321
348
  }
322
- }); // by clicking on the tree (using a live binding because content is not complete yet)
323
-
324
- $divContainer.off('click', '.folders a').on('click', '.folders a', function (e) {
325
- e.preventDefault();
326
- const $selected = $$1(this);
327
- const $folders = $$1('.folders li', $fileBrowser);
328
- const fullPath = $selected.data('path');
329
- const subTree = getByPath(fileTree, fullPath); //get the folder content
330
-
331
- getFolderContent(subTree, fullPath, function (content) {
332
- if (content) {
333
- //either create the inner list of the content is new or just show it
334
- let $innerList = $selected.siblings('ul');
335
-
336
- if (!$innerList.length && content.children && _.find(content.children, 'path') && !content.empty) {
337
- $innerList = $$1('<ul></ul>').insertAfter($selected);
338
- updateFolders(content, $innerList);
339
- $selected.addClass('opened');
340
- } else if ($innerList.length) {
341
- if ($innerList.css('display') === 'none') {
342
- $innerList.show();
343
- $selected.addClass('opened');
344
- } else if ($selected.parent('li').hasClass('active')) {
345
- $innerList.hide();
346
- $selected.removeClass('opened');
347
- }
348
- } //toggle active element
349
-
350
-
351
- $folders.removeClass('active');
352
- $selected.parent('li').addClass('active'); //internal event to set the file-selector content
353
-
354
- updateSelectedClass(fullPath, subTree.total, $selected.data('children-limit'));
355
- $container.trigger(`folderselect.${ns}`, [content.label, getPage(content.children), content.path, content]);
356
- renderPagination();
357
- }
358
- });
359
349
  });
360
- $container.on(`filenew.${ns}`, function (e, file, path) {
361
- const subTree = getByPath(fileTree, path);
350
+ });
351
+ $container.on("filenew.".concat(ns), function (e, file, path) {
352
+ var subTree = getByPath(fileTree, path);
362
353
 
363
- if (subTree) {
364
- if (!subTree.children) {
365
- subTree.children = [];
366
- }
367
-
368
- if (root !== 'local' || !_.find(subTree.children, {
369
- name: file.name
370
- })) {
371
- updatePermissions(file);
354
+ if (subTree) {
355
+ if (!subTree.children) {
356
+ subTree.children = [];
357
+ }
372
358
 
373
- if (subTree.children.length === subTree.total) {
374
- // all children loaded new file can be pushed to the end of tree
375
- // if not all, new file will be loaded with next page
376
- subTree.children.push(file);
377
- }
359
+ if (root !== 'local' || !_.find(subTree.children, {
360
+ name: file.name
361
+ })) {
362
+ updatePermissions(file);
378
363
 
379
- subTree.total++;
380
- selectedClass.total++;
381
- $container.trigger(`folderselect.${ns}`, [subTree.label, getPage(subTree.children), path]);
382
- renderPagination();
364
+ if (subTree.children.length === subTree.total) {
365
+ // all children loaded new file can be pushed to the end of tree
366
+ // if not all, new file will be loaded with next page
367
+ subTree.children.push(file);
383
368
  }
384
- }
385
- });
386
- $container.on(`filedelete.${ns}`, function (e, path) {
387
- if (removeFromPath(fileTree, path)) {
388
- selectedClass.total--;
389
- loadPage();
390
- }
391
- });
392
- /**
393
- * Get files for page
394
- * @param {Array} children
395
- * @returns {Array} files for this page
396
- */
397
-
398
- function getPage(children) {
399
- const files = _.filter(children, function (item) {
400
- return !!item.uri;
401
- });
402
369
 
403
- if (selectedClass.childrenLimit) {
404
- return files.slice((selectedClass.page - 1) * selectedClass.childrenLimit, selectedClass.page * selectedClass.childrenLimit);
370
+ subTree.total++;
371
+ selectedClass.total++;
372
+ $container.trigger("folderselect.".concat(ns), [subTree.label, getPage(subTree.children), path]);
373
+ renderPagination();
405
374
  }
375
+ }
376
+ });
377
+ $container.on("filedelete.".concat(ns), function (e, path) {
378
+ if (removeFromPath(fileTree, path)) {
379
+ selectedClass.total--;
380
+ loadPage();
381
+ }
382
+ });
383
+ /**
384
+ * Get files for page
385
+ * @param {Array} children
386
+ * @returns {Array} files for this page
387
+ */
388
+
389
+ function getPage(children) {
390
+ var files = _.filter(children, function (item) {
391
+ return !!item.uri;
392
+ });
406
393
 
407
- return files;
394
+ if (selectedClass.childrenLimit) {
395
+ return files.slice((selectedClass.page - 1) * selectedClass.childrenLimit, selectedClass.page * selectedClass.childrenLimit);
408
396
  }
409
- /**
410
- * Get the content of a folder, either in the model or load it
411
- * @param {Object} tree - the tree model
412
- * @param {String} path - the folder path (relative to the root)
413
- * @param {Function} cb - called back with the content in 1st parameter
414
- */
415
397
 
398
+ return files;
399
+ }
400
+ /**
401
+ * Get the content of a folder, either in the model or load it
402
+ * @param {Object} tree - the tree model
403
+ * @param {String} path - the folder path (relative to the root)
404
+ * @param {Function} cb - called back with the content in 1st parameter
405
+ */
416
406
 
417
- function getFolderContent(tree, path, cb) {
418
- let content = getByPath(tree, path);
419
407
 
420
- if (!content || !content.children && !content.empty) {
421
- loadContent(path).then(function (data) {
422
- if (!tree.path) {
423
- tree = _.merge(tree, data);
424
- } else if (data.children) {
425
- if (!_.find(data.children, 'path')) {
426
- // no subfolders inside folder
427
- tree.empty = true;
428
- }
429
-
430
- setToPath(tree, path, data);
431
- } else {
408
+ function getFolderContent(tree, path, cb) {
409
+ var content = getByPath(tree, path);
410
+
411
+ if (!content || !content.children && !content.empty) {
412
+ loadContent(path).then(function (data) {
413
+ if (!tree.path) {
414
+ tree = _.merge(tree, data);
415
+ } else if (data.children) {
416
+ if (!_.find(data.children, 'path')) {
417
+ // no subfolders inside folder
432
418
  tree.empty = true;
433
419
  }
434
420
 
435
- cb(data);
436
- });
437
- } else if (content.children) {
438
- const files = _.filter(content.children, function (item) {
439
- return !!item.uri;
440
- }); // if files less then total and need toload this page
441
-
442
-
443
- if (files.length < selectedClass.total && files.length < selectedClass.page * selectedClass.childrenLimit) {
444
- loadContent(path).then(function (data) {
445
- const loadedFiles = _.filter(data.children, function (item) {
446
- return !!item.uri;
447
- });
448
-
449
- setToPath(tree, path, {
450
- children: loadedFiles
451
- });
452
- content = getByPath(tree, path);
453
- cb(content);
454
- });
421
+ setToPath(tree, path, data);
455
422
  } else {
456
- cb(content);
423
+ tree.empty = true;
457
424
  }
425
+
426
+ cb(data);
427
+ });
428
+ } else if (content.children) {
429
+ var files = _.filter(content.children, function (item) {
430
+ return !!item.uri;
431
+ }); // if files less then total and need toload this page
432
+
433
+
434
+ if (files.length < selectedClass.total && files.length < selectedClass.page * selectedClass.childrenLimit) {
435
+ loadContent(path).then(function (data) {
436
+ var loadedFiles = _.filter(data.children, function (item) {
437
+ return !!item.uri;
438
+ });
439
+
440
+ setToPath(tree, path, {
441
+ children: loadedFiles
442
+ });
443
+ content = getByPath(tree, path);
444
+ cb(content);
445
+ });
458
446
  } else {
459
447
  cb(content);
460
448
  }
449
+ } else {
450
+ cb(content);
461
451
  }
462
- /**
463
- * Get a subTree from a path
464
- * @param {Object} tree - the tree model
465
- * @param {String} path - the path (relative to the root)
466
- * @returns {Object} the subtree that matches the path
467
- */
468
-
469
-
470
- function getByPath(tree, path) {
471
- let match;
472
-
473
- if (tree) {
474
- if (tree.path && tree.path.indexOf(path) === 0) {
475
- match = tree;
476
- } else if (tree.children) {
477
- _.forEach(tree.children, function (child) {
478
- match = getByPath(child, path);
479
-
480
- if (match) {
481
- return false;
482
- }
483
- });
484
- }
485
- }
452
+ }
453
+ /**
454
+ * Get a subTree from a path
455
+ * @param {Object} tree - the tree model
456
+ * @param {String} path - the path (relative to the root)
457
+ * @returns {Object} the subtree that matches the path
458
+ */
486
459
 
487
- return match;
488
- }
489
- /**
490
- * Merge data into at into the subtree
491
- * @param {Object} tree - the tree model
492
- * @param {String} path - the path (relative to the root)
493
- * @param {Object} data - the sbutree to merge at path level
494
- * @returns {Boolean} true if done
495
- */
496
-
497
-
498
- function setToPath(tree, path, data) {
499
- let done = false;
500
-
501
- if (tree) {
502
- if (tree.path === path) {
503
- tree.children = tree.children ? tree.children.concat(data.children) : data.children;
504
- tree.total = data.total;
505
- } else if (tree.children) {
506
- _.forEach(tree.children, function (child) {
507
- done = setToPath(child, path, data);
508
-
509
- if (done) {
510
- return false;
511
- }
512
- });
513
- }
514
- }
515
460
 
516
- return done;
461
+ function getByPath(tree, path) {
462
+ var match;
463
+
464
+ if (tree) {
465
+ if (tree.path && tree.path.indexOf(path) === 0) {
466
+ match = tree;
467
+ } else if (tree.children) {
468
+ _.forEach(tree.children, function (child) {
469
+ match = getByPath(child, path);
470
+
471
+ if (match) {
472
+ return false;
473
+ }
474
+ });
475
+ }
517
476
  }
518
- /**
519
- * Remove file from tree
520
- * @param {Object} tree - the tree model
521
- * @param {String} path - the path (relative to the root)
522
- * @returns {boolean} is file removed
523
- */
524
477
 
478
+ return match;
479
+ }
480
+ /**
481
+ * Merge data into at into the subtree
482
+ * @param {Object} tree - the tree model
483
+ * @param {String} path - the path (relative to the root)
484
+ * @param {Object} data - the sbutree to merge at path level
485
+ * @returns {Boolean} true if done
486
+ */
525
487
 
526
- function removeFromPath(tree, path) {
527
- let done = false;
528
- let removed = [];
529
488
 
530
- if (tree && tree.children) {
531
- removed = _.remove(tree.children, function (child) {
532
- return child.path === path || child.name && tree.path + child.name === path || child.uri === path;
533
- });
534
- done = removed.length > 0;
535
- tree.total--;
489
+ function setToPath(tree, path, data) {
490
+ var done = false;
536
491
 
537
- if (!done) {
538
- _.forEach(tree.children, function (child) {
539
- done = removeFromPath(child, path);
492
+ if (tree) {
493
+ if (tree.path === path) {
494
+ tree.children = tree.children ? tree.children.concat(data.children) : data.children;
495
+ tree.total = data.total;
496
+ } else if (tree.children) {
497
+ _.forEach(tree.children, function (child) {
498
+ done = setToPath(child, path, data);
540
499
 
541
- if (done) {
542
- return false;
543
- }
544
- });
545
- }
500
+ if (done) {
501
+ return false;
502
+ }
503
+ });
546
504
  }
547
-
548
- return done;
549
505
  }
550
- /**
551
- * Get the content of a folder
552
- * @param {String} path - the folder path
553
- * @returns {jQuery.Deferred} the defferred object to run done/complete/fail
554
- */
555
-
556
-
557
- function loadContent(path) {
558
- const parameters = {};
559
- parameters[options.pathParam] = path;
560
- return request({
561
- url: options.browseUrl,
562
- method: 'GET',
563
- dataType: 'json',
564
- data: _.merge(parameters, options.params, {
565
- childrenOffset: (selectedClass.page - 1) * selectedClass.childrenLimit
566
- }),
567
- noToken: true
568
- }).then(response => response.data).then(response => {
569
- response = updatePermissions(response);
570
-
571
- if (response.children && response.children.length > 0) {
572
- response.children.map(responseChildren => updatePermissions(responseChildren));
573
- }
574
506
 
575
- return response;
507
+ return done;
508
+ }
509
+ /**
510
+ * Remove file from tree
511
+ * @param {Object} tree - the tree model
512
+ * @param {String} path - the path (relative to the root)
513
+ * @returns {boolean} is file removed
514
+ */
515
+
516
+
517
+ function removeFromPath(tree, path) {
518
+ var done = false;
519
+ var removed = [];
520
+
521
+ if (tree && tree.children) {
522
+ removed = _.remove(tree.children, function (child) {
523
+ return child.path === path || child.name && tree.path + child.name === path || child.uri === path;
576
524
  });
577
- }
578
- /**
579
- * Update the HTML Tree
580
- * @param {Object} data - the tree data
581
- * @param {jQueryElement} $parent - the parent node to append the data
582
- * @param {Boolean} [recurse] - internal recursive condition
583
- */
584
-
585
-
586
- function updateFolders(data, $parent, recurse) {
587
- if (recurse && data && data.path) {
588
- if (typeof data.relPath === 'undefined') {
589
- data.relPath = data.path;
590
- }
525
+ done = removed.length > 0;
526
+ tree.total--;
591
527
 
592
- $parent.append(folderTpl(data));
593
- }
528
+ if (!done) {
529
+ _.forEach(tree.children, function (child) {
530
+ done = removeFromPath(child, path);
594
531
 
595
- if (data && data.children && _.isArray(data.children) && !data.empty) {
596
- _.forEach(data.children, function (child) {
597
- updateFolders(child, $parent, true);
532
+ if (done) {
533
+ return false;
534
+ }
598
535
  });
599
536
  }
600
537
  }
601
- /**
602
- * Update the selectedClass
603
- * @param {String} path - the folder path
604
- * @param {Number} total - files in class
605
- * @param {Number} childrenLimit - page size
606
- */
607
-
608
-
609
- function updateSelectedClass(path, total, childrenLimit) {
610
- selectedClass = {
611
- path,
612
- total,
613
- childrenLimit,
614
- page: 1
615
- };
616
- }
617
- /**
618
- * Render pagination
619
- */
620
-
621
-
622
- function renderPagination() {
623
- const $paginationContainer = $$1('.pagination-bottom', $container);
624
- $paginationContainer.empty();
625
- const totalPages = Math.ceil(selectedClass.total / selectedClass.childrenLimit);
626
-
627
- if (selectedClass.total && totalPages > 1) {
628
- paginationComponent({
629
- mode: 'simple',
630
- activePage: selectedClass.page,
631
- totalPages
632
- }).on('prev', function () {
633
- selectedClass.page--;
634
- loadPage();
635
- }).on('next', function () {
636
- selectedClass.page++;
637
- loadPage();
638
- }).render($paginationContainer);
538
+
539
+ return done;
540
+ }
541
+ /**
542
+ * Get the content of a folder
543
+ * @param {String} path - the folder path
544
+ * @returns {jQuery.Deferred} the defferred object to run done/complete/fail
545
+ */
546
+
547
+
548
+ function loadContent(path) {
549
+ var parameters = {};
550
+ parameters[options.pathParam] = path;
551
+ return request({
552
+ url: options.browseUrl,
553
+ method: 'GET',
554
+ dataType: 'json',
555
+ data: _.merge(parameters, options.params, {
556
+ childrenOffset: (selectedClass.page - 1) * selectedClass.childrenLimit
557
+ }),
558
+ noToken: true
559
+ }).then(function (response) {
560
+ return response.data;
561
+ }).then(function (response) {
562
+ response = updatePermissions(response);
563
+
564
+ if (response.children && response.children.length > 0) {
565
+ response.children.map(function (responseChildren) {
566
+ return updatePermissions(responseChildren);
567
+ });
639
568
  }
640
- }
641
- /**
642
- * Load page
643
- */
644
569
 
570
+ return response;
571
+ });
572
+ }
573
+ /**
574
+ * Update the HTML Tree
575
+ * @param {Object} data - the tree data
576
+ * @param {jQueryElement} $parent - the parent node to append the data
577
+ * @param {Boolean} [recurse] - internal recursive condition
578
+ */
645
579
 
646
- function loadPage() {
647
- const subTree = getByPath(fileTree, selectedClass.path); //get the folder content
648
580
 
649
- getFolderContent(subTree, selectedClass.path, function (content) {
650
- if (content) {
651
- //internal event to set the file-selector content
652
- $container.trigger(`folderselect.${ns}`, [content.label, getPage(content.children), content.path]);
653
- }
581
+ function updateFolders(data, $parent, recurse) {
582
+ if (recurse && data && data.path) {
583
+ if (typeof data.relPath === 'undefined') {
584
+ data.relPath = data.path;
585
+ }
586
+
587
+ $parent.append(folderTpl(data));
588
+ }
589
+
590
+ if (data && data.children && _.isArray(data.children) && !data.empty) {
591
+ _.forEach(data.children, function (child) {
592
+ updateFolders(child, $parent, true);
654
593
  });
655
594
  }
656
595
  }
596
+ /**
597
+ * Update the selectedClass
598
+ * @param {String} path - the folder path
599
+ * @param {Number} total - files in class
600
+ * @param {Number} childrenLimit - page size
601
+ */
602
+
603
+
604
+ function updateSelectedClass(path, total, childrenLimit) {
605
+ selectedClass = {
606
+ path: path,
607
+ total: total,
608
+ childrenLimit: childrenLimit,
609
+ page: 1
610
+ };
611
+ }
612
+ /**
613
+ * Render pagination
614
+ */
615
+
616
+
617
+ function renderPagination() {
618
+ var $paginationContainer = $$1('.pagination-bottom', $container);
619
+ $paginationContainer.empty();
620
+ var totalPages = Math.ceil(selectedClass.total / selectedClass.childrenLimit);
621
+
622
+ if (selectedClass.total && totalPages > 1) {
623
+ paginationComponent({
624
+ mode: 'simple',
625
+ activePage: selectedClass.page,
626
+ totalPages: totalPages
627
+ }).on('prev', function () {
628
+ selectedClass.page--;
629
+ loadPage();
630
+ }).on('next', function () {
631
+ selectedClass.page++;
632
+ loadPage();
633
+ }).render($paginationContainer);
634
+ }
635
+ }
636
+ /**
637
+ * Load page
638
+ */
639
+
640
+
641
+ function loadPage() {
642
+ var subTree = getByPath(fileTree, selectedClass.path); //get the folder content
643
+
644
+ getFolderContent(subTree, selectedClass.path, function (content) {
645
+ if (content) {
646
+ //internal event to set the file-selector content
647
+ $container.trigger("folderselect.".concat(ns), [content.label, getPage(content.children), content.path]);
648
+ }
649
+ });
650
+ }
651
+ }
657
652
 
658
- return fileBrowser;
653
+ return fileBrowser;
659
654
 
660
655
  });