@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,1002 +1,993 @@
1
1
  define(['jquery', 'lodash', 'i18n', 'ui/component', 'ui/hider', 'ui/class/selector', 'ui/resource/tree', 'ui/resource/list', 'ui/resource/filters', 'handlebars', 'lib/dompurify/purify', 'css!ui/resource/css/selector.css'], function ($$1, _, __, component, hider, classesSelectorFactory, treeFactory, listFactory, filtersFactory, Handlebars, DOMPurify, selector_css) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
6
- component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
7
- hider = hider && Object.prototype.hasOwnProperty.call(hider, 'default') ? hider['default'] : hider;
8
- classesSelectorFactory = classesSelectorFactory && Object.prototype.hasOwnProperty.call(classesSelectorFactory, 'default') ? classesSelectorFactory['default'] : classesSelectorFactory;
9
- treeFactory = treeFactory && Object.prototype.hasOwnProperty.call(treeFactory, 'default') ? treeFactory['default'] : treeFactory;
10
- listFactory = listFactory && Object.prototype.hasOwnProperty.call(listFactory, 'default') ? listFactory['default'] : listFactory;
11
- filtersFactory = filtersFactory && Object.prototype.hasOwnProperty.call(filtersFactory, 'default') ? filtersFactory['default'] : filtersFactory;
12
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
13
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
14
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
6
+ component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
7
+ hider = hider && Object.prototype.hasOwnProperty.call(hider, 'default') ? hider['default'] : hider;
8
+ classesSelectorFactory = classesSelectorFactory && Object.prototype.hasOwnProperty.call(classesSelectorFactory, 'default') ? classesSelectorFactory['default'] : classesSelectorFactory;
9
+ treeFactory = treeFactory && Object.prototype.hasOwnProperty.call(treeFactory, 'default') ? treeFactory['default'] : treeFactory;
10
+ listFactory = listFactory && Object.prototype.hasOwnProperty.call(listFactory, 'default') ? listFactory['default'] : listFactory;
11
+ filtersFactory = filtersFactory && Object.prototype.hasOwnProperty.call(filtersFactory, 'default') ? filtersFactory['default'] : filtersFactory;
12
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
13
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
14
+
15
+ function _typeof(obj) {
16
+ "@babel/helpers - typeof";
17
+
18
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
19
+ return typeof obj;
20
+ } : function (obj) {
21
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
22
+ }, _typeof(obj);
23
+ }
24
+
25
+ function Helpers0 (hb) {
26
+ //register a i18n helper
27
+ hb.registerHelper('__', function (key) {
28
+ return __(key);
29
+ });
15
30
  /**
16
- * This program is free software; you can redistribute it and/or
17
- * modify it under the terms of the GNU General Public License
18
- * as published by the Free Software Foundation; under version 2
19
- * of the License (non-upgradable).
20
- *
21
- * This program is distributed in the hope that it will be useful,
22
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- * GNU General Public License for more details.
25
- *
26
- * You should have received a copy of the GNU General Public License
27
- * along with this program; if not, write to the Free Software
28
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
- *
30
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
31
- *
31
+ * Register dompurify helper
32
32
  *
33
+ * https://github.com/cure53/DOMPurify
34
+ * with config SAFE_FOR_TEMPLATES: true
35
+ * to make output safe for template systems
33
36
  */
34
- function Helpers0 (hb) {
35
- //register a i18n helper
36
- hb.registerHelper('__', function (key) {
37
- return __(key);
38
- });
39
- /**
40
- * Register dompurify helper
41
- *
42
- * https://github.com/cure53/DOMPurify
43
- * with config SAFE_FOR_TEMPLATES: true
44
- * to make output safe for template systems
45
- */
46
37
 
47
- hb.registerHelper('dompurify', function (context) {
48
- return DOMPurify.sanitize(context);
49
- });
50
- /**
51
- * Register join helper
52
- *
53
- * Example :
54
- * var values = {a:v1, b:v2, c:v3};
55
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
56
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
57
- */
58
-
59
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
60
- var fragments = [];
61
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
62
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
63
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
38
+ hb.registerHelper('dompurify', function (context) {
39
+ return DOMPurify.sanitize(context);
40
+ });
41
+ /**
42
+ * Register join helper
43
+ *
44
+ * Example :
45
+ * var values = {a:v1, b:v2, c:v3};
46
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
47
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
48
+ */
64
49
 
65
- _.forIn(arr, function (value, key) {
66
- var fragment = '';
50
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
51
+ var fragments = [];
52
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
53
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
54
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
67
55
 
68
- if (value !== null || value !== undefined) {
69
- if (typeof value === 'boolean') {
70
- value = value ? 'true' : 'false';
71
- } else if (typeof value === 'object') {
72
- value = _.values(value).join(' ');
73
- }
74
- } else {
75
- value = '';
76
- }
56
+ _.forIn(arr, function (value, key) {
57
+ var fragment = '';
77
58
 
78
- if (keyValueGlue !== undefined) {
79
- fragment += key + keyValueGlue;
59
+ if (value !== null || value !== undefined) {
60
+ if (typeof value === 'boolean') {
61
+ value = value ? 'true' : 'false';
62
+ } else if (_typeof(value) === 'object') {
63
+ value = _.values(value).join(' ');
80
64
  }
65
+ } else {
66
+ value = '';
67
+ }
81
68
 
82
- fragment += wrapper + value + wrapper;
83
- fragments.push(fragment);
84
- });
85
-
86
- return fragments.join(fragmentGlue);
87
- }); //register a classic "for loop" helper
88
- //it also adds a local variable "i" as the index in each iteration loop
89
-
90
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
91
- var ret = '';
92
- startIndex = parseInt(startIndex);
93
- stopIndex = parseInt(stopIndex);
94
- increment = parseInt(increment);
95
-
96
- for (var i = startIndex; i < stopIndex; i += increment) {
97
- ret += options.fn(_.extend({}, this, {
98
- i: i
99
- }));
69
+ if (keyValueGlue !== undefined) {
70
+ fragment += key + keyValueGlue;
100
71
  }
101
72
 
102
- return ret;
73
+ fragment += wrapper + value + wrapper;
74
+ fragments.push(fragment);
103
75
  });
104
- hb.registerHelper('equal', function (var1, var2, options) {
105
- if (var1 == var2) {
106
- return options.fn(this);
107
- } else {
108
- return options.inverse(this);
109
- }
110
- }); // register a "get property" helper
111
- // it gets the named property from the provided context
112
76
 
113
- hb.registerHelper('property', function (name, context) {
114
- return context[name] || '';
115
- }); // register an 'includes' helper
116
- // it checks if value is in array
77
+ return fragments.join(fragmentGlue);
78
+ }); //register a classic "for loop" helper
79
+ //it also adds a local variable "i" as the index in each iteration loop
117
80
 
118
- hb.registerHelper('includes', function (haystack, needle, options) {
119
- if (_.contains(haystack, needle)) {
120
- return options.fn(this);
121
- }
122
- });
123
- }
81
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
82
+ var ret = '';
83
+ startIndex = parseInt(startIndex);
84
+ stopIndex = parseInt(stopIndex);
85
+ increment = parseInt(increment);
124
86
 
125
- if (!Helpers0.__initialized) {
126
- Helpers0(Handlebars);
127
- Helpers0.__initialized = true;
128
- }
129
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
130
- this.compilerInfo = [4,'>= 1.0.0'];
131
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
132
- var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing;
133
-
134
- function program1(depth0,data) {
135
-
136
-
137
- return "multiple";
87
+ for (var i = startIndex; i < stopIndex; i += increment) {
88
+ ret += options.fn(_.extend({}, this, {
89
+ i: i
90
+ }));
138
91
  }
139
92
 
140
- function program3(depth0,data) {
141
-
142
- var buffer = "", stack1;
143
- buffer += "\n <nav class=\"context\">\n <div class=\"class-context\"></div>\n ";
144
- stack1 = helpers.each.call(depth0, (depth0 && depth0.formats), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
145
- if(stack1 || stack1 === 0) { buffer += stack1; }
146
- buffer += "\n </nav>\n ";
147
- return buffer;
148
- }
149
- function program4(depth0,data) {
150
-
151
- var buffer = "", stack1, helper;
152
- buffer += "\n <a href=\"#\" data-view-format=\""
153
- + escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
154
- + "\" ";
155
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.active), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
156
- if(stack1 || stack1 === 0) { buffer += stack1; }
157
- buffer += " ";
158
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.title), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
159
- if(stack1 || stack1 === 0) { buffer += stack1; }
160
- buffer += "><span class=\"";
161
- if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
162
- else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
163
- buffer += escapeExpression(stack1)
164
- + "\"></span></a>\n ";
165
- return buffer;
166
- }
167
- function program5(depth0,data) {
168
-
169
-
170
- return "class=\"active\"";
93
+ return ret;
94
+ });
95
+ hb.registerHelper('equal', function (var1, var2, options) {
96
+ if (var1 == var2) {
97
+ return options.fn(this);
98
+ } else {
99
+ return options.inverse(this);
171
100
  }
101
+ }); // register a "get property" helper
102
+ // it gets the named property from the provided context
172
103
 
173
- function program7(depth0,data) {
174
-
175
- var buffer = "", stack1, helper;
176
- buffer += "title=\"";
177
- if (helper = helpers.title) { stack1 = helper.call(depth0, {hash:{},data:data}); }
178
- else { helper = (depth0 && depth0.title); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
179
- buffer += escapeExpression(stack1)
180
- + "\"";
181
- return buffer;
182
- }
104
+ hb.registerHelper('property', function (name, context) {
105
+ return context[name] || '';
106
+ }); // register an 'includes' helper
107
+ // it checks if value is in array
183
108
 
184
- function program9(depth0,data) {
185
-
186
- var buffer = "", stack1, helper, options;
187
- buffer += "\n <nav class=\"selection\">\n <div class=\"search\">\n <input type=\"text\" placeholder=\"";
188
- if (helper = helpers.searchPlaceholder) { stack1 = helper.call(depth0, {hash:{},data:data}); }
189
- else { helper = (depth0 && depth0.searchPlaceholder); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
190
- buffer += escapeExpression(stack1)
191
- + "\" />\n ";
192
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
193
- if(stack1 || stack1 === 0) { buffer += stack1; }
194
- buffer += "\n </div>\n <div class=\"selection-control\">\n <a href=\"#\" class=\"selection-toggle ";
195
- stack1 = helpers.unless.call(depth0, (depth0 && depth0.switchMode), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
196
- if(stack1 || stack1 === 0) { buffer += stack1; }
197
- buffer += "\" title=\""
198
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle multiple/single selection", options) : helperMissing.call(depth0, "__", "Toggle multiple/single selection", options)))
199
- + "\">\n <span class=\"icon-multi-select\"></span>\n </a>\n <label class=\"selection-indicator ";
200
- stack1 = helpers.unless.call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
201
- if(stack1 || stack1 === 0) { buffer += stack1; }
202
- buffer += "\">\n <input type=\"checkbox\">\n <span class=\"icon-checkbox\"></span>\n </label>\n </div>\n ";
203
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
204
- if(stack1 || stack1 === 0) { buffer += stack1; }
205
- buffer += "\n </nav>\n ";
206
- return buffer;
207
- }
208
- function program10(depth0,data) {
209
-
210
- var buffer = "", helper, options;
211
- buffer += "\n <a href=\"#\" class=\"filters-opener\" title=\""
212
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Advanced search, add filters", options) : helperMissing.call(depth0, "__", "Advanced search, add filters", options)))
213
- + "\"><span class=\"icon-add\"></span></a>\n ";
214
- return buffer;
109
+ hb.registerHelper('includes', function (haystack, needle, options) {
110
+ if (_.contains(haystack, needle)) {
111
+ return options.fn(this);
215
112
  }
113
+ });
114
+ }
115
+
116
+ if (!Helpers0.__initialized) {
117
+ Helpers0(Handlebars);
118
+ Helpers0.__initialized = true;
119
+ }
120
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
121
+ this.compilerInfo = [4,'>= 1.0.0'];
122
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
123
+ var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing;
124
+
125
+ function program1(depth0,data) {
126
+
127
+
128
+ return "multiple";
129
+ }
216
130
 
217
- function program12(depth0,data) {
218
-
219
-
220
- return "hidden";
221
- }
131
+ function program3(depth0,data) {
132
+
133
+ var buffer = "", stack1;
134
+ buffer += "\n <nav class=\"context\">\n <div class=\"class-context\"></div>\n ";
135
+ stack1 = helpers.each.call(depth0, (depth0 && depth0.formats), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
136
+ if(stack1 || stack1 === 0) { buffer += stack1; }
137
+ buffer += "\n </nav>\n ";
138
+ return buffer;
139
+ }
140
+ function program4(depth0,data) {
141
+
142
+ var buffer = "", stack1, helper;
143
+ buffer += "\n <a href=\"#\" data-view-format=\""
144
+ + escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
145
+ + "\" ";
146
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.active), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
147
+ if(stack1 || stack1 === 0) { buffer += stack1; }
148
+ buffer += " ";
149
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.title), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
150
+ if(stack1 || stack1 === 0) { buffer += stack1; }
151
+ buffer += "><span class=\"";
152
+ if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
153
+ else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
154
+ buffer += escapeExpression(stack1)
155
+ + "\"></span></a>\n ";
156
+ return buffer;
157
+ }
158
+ function program5(depth0,data) {
159
+
160
+
161
+ return "class=\"active\"";
162
+ }
222
163
 
223
- function program14(depth0,data) {
224
-
225
-
226
- return "\n <div class=\"filters-container folded\"></div>\n ";
227
- }
164
+ function program7(depth0,data) {
165
+
166
+ var buffer = "", stack1, helper;
167
+ buffer += "title=\"";
168
+ if (helper = helpers.title) { stack1 = helper.call(depth0, {hash:{},data:data}); }
169
+ else { helper = (depth0 && depth0.title); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
170
+ buffer += escapeExpression(stack1)
171
+ + "\"";
172
+ return buffer;
173
+ }
228
174
 
229
- function program16(depth0,data) {
230
-
231
- var buffer = "", stack1, helper, options;
232
- buffer += "\n <footer>\n <div class=\"get-selection\">\n <span>"
233
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Selected", options) : helperMissing.call(depth0, "__", "Selected", options)))
234
- + " ";
235
- if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
236
- else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
237
- buffer += escapeExpression(stack1)
238
- + " : </span><span class=\"selected-num\">0</span>\n </div>\n </footer>\n ";
239
- return buffer;
240
- }
175
+ function program9(depth0,data) {
176
+
177
+ var buffer = "", stack1, helper, options;
178
+ buffer += "\n <nav class=\"selection\">\n <div class=\"search\">\n <input type=\"text\" placeholder=\"";
179
+ if (helper = helpers.searchPlaceholder) { stack1 = helper.call(depth0, {hash:{},data:data}); }
180
+ else { helper = (depth0 && depth0.searchPlaceholder); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
181
+ buffer += escapeExpression(stack1)
182
+ + "\" />\n ";
183
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
184
+ if(stack1 || stack1 === 0) { buffer += stack1; }
185
+ buffer += "\n </div>\n <div class=\"selection-control\">\n <a href=\"#\" class=\"selection-toggle ";
186
+ stack1 = helpers.unless.call(depth0, (depth0 && depth0.switchMode), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
187
+ if(stack1 || stack1 === 0) { buffer += stack1; }
188
+ buffer += "\" title=\""
189
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle multiple/single selection", options) : helperMissing.call(depth0, "__", "Toggle multiple/single selection", options)))
190
+ + "\">\n <span class=\"icon-multi-select\"></span>\n </a>\n <label class=\"selection-indicator ";
191
+ stack1 = helpers.unless.call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
192
+ if(stack1 || stack1 === 0) { buffer += stack1; }
193
+ buffer += "\">\n <input type=\"checkbox\">\n <span class=\"icon-checkbox\"></span>\n </label>\n </div>\n ";
194
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
195
+ if(stack1 || stack1 === 0) { buffer += stack1; }
196
+ buffer += "\n </nav>\n ";
197
+ return buffer;
198
+ }
199
+ function program10(depth0,data) {
200
+
201
+ var buffer = "", helper, options;
202
+ buffer += "\n <a href=\"#\" class=\"filters-opener\" title=\""
203
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Advanced search, add filters", options) : helperMissing.call(depth0, "__", "Advanced search, add filters", options)))
204
+ + "\"><span class=\"icon-add\"></span></a>\n ";
205
+ return buffer;
206
+ }
241
207
 
242
- buffer += "<div class=\"resource-selector ";
243
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
244
- if(stack1 || stack1 === 0) { buffer += stack1; }
245
- buffer += "\">\n\n ";
246
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.showContext), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
247
- if(stack1 || stack1 === 0) { buffer += stack1; }
248
- buffer += "\n\n ";
249
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.showSelection), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
250
- if(stack1 || stack1 === 0) { buffer += stack1; }
251
- buffer += "\n\n <main>\n <span class=\"hidden no-results\">";
252
- if (helper = helpers.noResultsText) { stack1 = helper.call(depth0, {hash:{},data:data}); }
253
- else { helper = (depth0 && depth0.noResultsText); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
254
- buffer += escapeExpression(stack1)
255
- + "</span>\n </main>\n\n ";
256
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
257
- if(stack1 || stack1 === 0) { buffer += stack1; }
258
- buffer += "\n</div>\n";
259
- return buffer;
260
- });
261
- function selectorTpl(data, options, asString) {
262
- var html = Template(data, options);
263
- return (asString || true) ? html : $(html);
208
+ function program12(depth0,data) {
209
+
210
+
211
+ return "hidden";
264
212
  }
265
213
 
266
- /**
267
- * This program is free software; you can redistribute it and/or
268
- * modify it under the terms of the GNU General Public License
269
- * as published by the Free Software Foundation; under version 2
270
- * of the License (non-upgradable).
271
- *
272
- * This program is distributed in the hope that it will be useful,
273
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
274
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
275
- * GNU General Public License for more details.
276
- *
277
- * You should have received a copy of the GNU General Public License
278
- * along with this program; if not, write to the Free Software
279
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
280
- *
281
- * Copyright (c) 2017-2019 (original work) Open Assessment Technologies SA ;
282
- */
283
- var labelUri = 'http://www.w3.org/2000/01/rdf-schema#label';
284
- var nodeTypes = {
285
- instance: 'instance',
286
- class: 'class'
287
- };
288
- var selectionModes = {
289
- single: 'single',
290
- multiple: 'multiple',
291
- both: 'both'
292
- };
293
- var selectAllPolicies = {
294
- all: 'all',
295
- // should select 100% of the nodes, but currently not implementable due to lazy loading
296
- loaded: 'loaded',
297
- // selects all loaded nodes, whether visible or not
298
- visible: 'visible' // selects only visible nodes
214
+ function program14(depth0,data) {
215
+
216
+
217
+ return "\n <div class=\"filters-container folded\"></div>\n ";
218
+ }
299
219
 
300
- };
301
- var defaultConfig = {
302
- type: __('resources'),
303
- noResultsText: _('No resources found'),
304
- searchPlaceholder: __('Search'),
305
- icon: 'item',
306
- selectionMode: selectionModes.single,
307
- selectClass: false,
308
- selectAllPolicy: selectAllPolicies.loaded,
309
- filters: false,
310
- showContext: true,
311
- showSelection: true,
312
- formats: {
313
- list: {
314
- icon: 'icon-ul',
315
- title: __('View resources as a list'),
316
- componentFactory: listFactory
317
- },
318
- tree: {
319
- icon: 'icon-tree',
320
- title: __('View resources as a tree'),
321
- componentFactory: treeFactory,
322
- active: true
323
- }
324
- },
325
- limit: 30
326
- };
327
- /**
328
- * Filter and extract classes from a resource tree
329
- * @param {Object[]} resources - the resource tree
330
- * @returns {Object[]} contains only classes with URI and label
331
- */
220
+ function program16(depth0,data) {
221
+
222
+ var buffer = "", stack1, helper, options;
223
+ buffer += "\n <footer>\n <div class=\"get-selection\">\n <span>"
224
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Selected", options) : helperMissing.call(depth0, "__", "Selected", options)))
225
+ + " ";
226
+ if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
227
+ else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
228
+ buffer += escapeExpression(stack1)
229
+ + " : </span><span class=\"selected-num\">0</span>\n </div>\n </footer>\n ";
230
+ return buffer;
231
+ }
332
232
 
333
- var filterClasses = function filterClasses(resources) {
334
- return _(resources).filter({
335
- type: nodeTypes.class
336
- }).map(function (resource) {
337
- var classNode = _.pick(resource, ['uri', 'label', 'state']);
233
+ buffer += "<div class=\"resource-selector ";
234
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
235
+ if(stack1 || stack1 === 0) { buffer += stack1; }
236
+ buffer += "\">\n\n ";
237
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.showContext), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
238
+ if(stack1 || stack1 === 0) { buffer += stack1; }
239
+ buffer += "\n\n ";
240
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.showSelection), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
241
+ if(stack1 || stack1 === 0) { buffer += stack1; }
242
+ buffer += "\n\n <main>\n <span class=\"hidden no-results\">";
243
+ if (helper = helpers.noResultsText) { stack1 = helper.call(depth0, {hash:{},data:data}); }
244
+ else { helper = (depth0 && depth0.noResultsText); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
245
+ buffer += escapeExpression(stack1)
246
+ + "</span>\n </main>\n\n ";
247
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
248
+ if(stack1 || stack1 === 0) { buffer += stack1; }
249
+ buffer += "\n</div>\n";
250
+ return buffer;
251
+ });
252
+ function selectorTpl(data, options, asString) {
253
+ var html = Template(data, options);
254
+ return (asString || true) ? html : $(html);
255
+ }
256
+
257
+ /**
258
+ * This program is free software; you can redistribute it and/or
259
+ * modify it under the terms of the GNU General Public License
260
+ * as published by the Free Software Foundation; under version 2
261
+ * of the License (non-upgradable).
262
+ *
263
+ * This program is distributed in the hope that it will be useful,
264
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
265
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
266
+ * GNU General Public License for more details.
267
+ *
268
+ * You should have received a copy of the GNU General Public License
269
+ * along with this program; if not, write to the Free Software
270
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
271
+ *
272
+ * Copyright (c) 2017-2019 (original work) Open Assessment Technologies SA ;
273
+ */
274
+ var labelUri = 'http://www.w3.org/2000/01/rdf-schema#label';
275
+ var nodeTypes = {
276
+ instance: 'instance',
277
+ class: 'class'
278
+ };
279
+ var selectionModes = {
280
+ single: 'single',
281
+ multiple: 'multiple',
282
+ both: 'both'
283
+ };
284
+ var selectAllPolicies = {
285
+ all: 'all',
286
+ // should select 100% of the nodes, but currently not implementable due to lazy loading
287
+ loaded: 'loaded',
288
+ // selects all loaded nodes, whether visible or not
289
+ visible: 'visible' // selects only visible nodes
290
+
291
+ };
292
+ var defaultConfig = {
293
+ type: __('resources'),
294
+ noResultsText: _('No resources found'),
295
+ searchPlaceholder: __('Search'),
296
+ icon: 'item',
297
+ selectionMode: selectionModes.single,
298
+ selectClass: false,
299
+ selectAllPolicy: selectAllPolicies.loaded,
300
+ filters: false,
301
+ showContext: true,
302
+ showSelection: true,
303
+ formats: {
304
+ list: {
305
+ icon: 'icon-ul',
306
+ title: __('View resources as a list'),
307
+ componentFactory: listFactory
308
+ },
309
+ tree: {
310
+ icon: 'icon-tree',
311
+ title: __('View resources as a tree'),
312
+ componentFactory: treeFactory,
313
+ active: true
314
+ }
315
+ },
316
+ limit: 30
317
+ };
318
+ /**
319
+ * Filter and extract classes from a resource tree
320
+ * @param {Object[]} resources - the resource tree
321
+ * @returns {Object[]} contains only classes with URI and label
322
+ */
323
+
324
+ var filterClasses = function filterClasses(resources) {
325
+ return _(resources).filter({
326
+ type: nodeTypes.class
327
+ }).map(function (resource) {
328
+ var classNode = _.pick(resource, ['uri', 'label', 'state']);
329
+
330
+ if (resource.children) {
331
+ classNode.children = filterClasses(resource.children);
332
+ }
338
333
 
339
- if (resource.children) {
340
- classNode.children = filterClasses(resource.children);
334
+ return classNode;
335
+ }).value();
336
+ };
337
+ /**
338
+ * The factory that creates the resource selector component
339
+ *
340
+ * @param {jQueryElement} $container - where to append the component
341
+ * @param {Object} config - the component config
342
+ * @param {String} config.classUri - the root Class URI
343
+ * @param {Object|[]} [config.classes] - the classes hierarchy for the class selector
344
+ * @param {Object[]} config.formats - the definition of the supported viewer/selector component
345
+ * @param {Object[]} [config.nodes] - the nodes to preload, the format is up to the formatComponent
346
+ * @param {String} [config.icon] - the icon class that represents a resource
347
+ * @param {String} [config.type] - describes the resource type
348
+ * @param {Boolean} [config.selectionMode] - multiple or single selection mode
349
+ * @param {Number} [config.limit = 30] - the default page size for data paging
350
+ * @param {Object|Boolean} [config.filters = false] - false or filters config, see ui/resource/filters
351
+ * @param {Boolean} [config.showContext = true] - show the context bar (class and format switch)
352
+ * @param {Boolean} [config.showSelection = true] - show the selection bar (search, multi switch and select all)
353
+ * @returns {resourceSelector} the component
354
+ */
355
+
356
+
357
+ var resourceSelectorFactory = function resourceSelectorFactory($container, config) {
358
+ var $classContainer;
359
+ var $resultArea;
360
+ var $noResults;
361
+ var $searchField;
362
+ var $viewFormats;
363
+ var $selectNum;
364
+ var $selectCtrl;
365
+ var $selectCtrlLabel;
366
+ var $filterToggle;
367
+ var $filterContainer;
368
+ var $selectionToggle;
369
+ var resourceSelectorApi = {
370
+ /**
371
+ * Empty the selection component
372
+ * @returns {resourceSelector} chains
373
+ * @fires resourceSelector#empty
374
+ */
375
+ empty: function empty() {
376
+ if (this.is('rendered')) {
377
+ if (this.selectionComponent) {
378
+ this.selectionComponent.destroy();
379
+ this.selectionComponent = null;
380
+ }
341
381
  }
342
382
 
343
- return classNode;
344
- }).value();
345
- };
346
- /**
347
- * The factory that creates the resource selector component
348
- *
349
- * @param {jQueryElement} $container - where to append the component
350
- * @param {Object} config - the component config
351
- * @param {String} config.classUri - the root Class URI
352
- * @param {Object|[]} [config.classes] - the classes hierarchy for the class selector
353
- * @param {Object[]} config.formats - the definition of the supported viewer/selector component
354
- * @param {Object[]} [config.nodes] - the nodes to preload, the format is up to the formatComponent
355
- * @param {String} [config.icon] - the icon class that represents a resource
356
- * @param {String} [config.type] - describes the resource type
357
- * @param {Boolean} [config.selectionMode] - multiple or single selection mode
358
- * @param {Number} [config.limit = 30] - the default page size for data paging
359
- * @param {Object|Boolean} [config.filters = false] - false or filters config, see ui/resource/filters
360
- * @param {Boolean} [config.showContext = true] - show the context bar (class and format switch)
361
- * @param {Boolean} [config.showSelection = true] - show the selection bar (search, multi switch and select all)
362
- * @returns {resourceSelector} the component
363
- */
383
+ return this.trigger('empty');
384
+ },
364
385
 
386
+ /**
387
+ * Reset the selector
388
+ * @returns {resourceSelector} chains
389
+ * @fires resourceSelector#reset
390
+ */
391
+ reset: function reset() {
392
+ if (this.is('rendered')) {
393
+ this.empty();
394
+ this.searchQuery = {};
365
395
 
366
- var resourceSelectorFactory = function resourceSelectorFactory($container, config) {
367
- var $classContainer;
368
- var $resultArea;
369
- var $noResults;
370
- var $searchField;
371
- var $viewFormats;
372
- var $selectNum;
373
- var $selectCtrl;
374
- var $selectCtrlLabel;
375
- var $filterToggle;
376
- var $filterContainer;
377
- var $selectionToggle;
378
- var resourceSelectorApi = {
379
- /**
380
- * Empty the selection component
381
- * @returns {resourceSelector} chains
382
- * @fires resourceSelector#empty
383
- */
384
- empty: function empty() {
385
- if (this.is('rendered')) {
386
- if (this.selectionComponent) {
387
- this.selectionComponent.destroy();
388
- this.selectionComponent = null;
396
+ if (this.config.filters) {
397
+ if (this.filtersComponent) {
398
+ this.filtersComponent.reset();
389
399
  }
400
+
401
+ $searchField.val('').attr('title', null).attr('placeholder', this.config.searchPlaceholder);
390
402
  }
403
+ }
391
404
 
392
- return this.trigger('empty');
393
- },
405
+ return this.trigger('reset');
406
+ },
394
407
 
395
- /**
396
- * Reset the selector
397
- * @returns {resourceSelector} chains
398
- * @fires resourceSelector#reset
399
- */
400
- reset: function reset() {
401
- if (this.is('rendered')) {
402
- this.empty();
403
- this.searchQuery = {};
408
+ /**
409
+ * Get the selected nodes
410
+ * @returns {Object?} the selection
411
+ */
412
+ getSelection: function getSelection() {
413
+ if (this.selectionComponent) {
414
+ return this.selectionComponent.getSelection();
415
+ }
404
416
 
405
- if (this.config.filters) {
406
- if (this.filtersComponent) {
407
- this.filtersComponent.reset();
408
- }
417
+ return null;
418
+ },
409
419
 
410
- $searchField.val('').attr('title', null).attr('placeholder', this.config.searchPlaceholder);
411
- }
412
- }
420
+ /**
421
+ * Clear the current selection
422
+ * @returns {resourceSelector} chains
423
+ */
424
+ clearSelection: function clearSelection() {
425
+ if (this.selectionComponent) {
426
+ this.selectionComponent.clearSelection();
427
+ }
413
428
 
414
- return this.trigger('reset');
415
- },
429
+ return this;
430
+ },
416
431
 
417
- /**
418
- * Get the selected nodes
419
- * @returns {Object?} the selection
420
- */
421
- getSelection: function getSelection() {
422
- if (this.selectionComponent) {
423
- return this.selectionComponent.getSelection();
424
- }
432
+ /**
433
+ * Set the search query
434
+ * @param {String|Object} query - label query if string or property filters
435
+ * @returns {resourceSelector} chains
436
+ */
437
+ setSearchQuery: function setSearchQuery(query) {
438
+ this.searchQuery = {};
439
+ this.searchQuery[labelUri] = '';
425
440
 
426
- return null;
427
- },
441
+ if (_.isString(query) && !_.isEmpty(query)) {
442
+ this.searchQuery[labelUri] = query;
443
+ }
428
444
 
429
- /**
430
- * Clear the current selection
431
- * @returns {resourceSelector} chains
432
- */
433
- clearSelection: function clearSelection() {
434
- if (this.selectionComponent) {
435
- this.selectionComponent.clearSelection();
436
- }
445
+ if (_.isPlainObject(query)) {
446
+ this.searchQuery = query;
447
+ }
437
448
 
438
- return this;
439
- },
449
+ return this;
450
+ },
440
451
 
441
- /**
442
- * Set the search query
443
- * @param {String|Object} query - label query if string or property filters
444
- * @returns {resourceSelector} chains
445
- */
446
- setSearchQuery: function setSearchQuery(query) {
447
- this.searchQuery = {};
452
+ /**
453
+ * Clear the search query to submit
454
+ * @returns {Object} the query
455
+ */
456
+ getSearchQuery: function getSearchQuery() {
457
+ if (_.size(this.searchQuery) === 0) {
448
458
  this.searchQuery[labelUri] = '';
459
+ }
449
460
 
450
- if (_.isString(query) && !_.isEmpty(query)) {
451
- this.searchQuery[labelUri] = query;
452
- }
461
+ return this.searchQuery;
462
+ },
453
463
 
454
- if (_.isPlainObject(query)) {
455
- this.searchQuery = query;
456
- }
464
+ /**
465
+ * Ask for a query (forward the event)
466
+ * @param {Object} [params] - the query parameters
467
+ * @param {String} [params.classUri] - the current node class URI
468
+ * @param {String} [params.format] - the selected format
469
+ * @param {String} [params.search] - the search query
470
+ * @param {Number} [params.offset = 0] - for paging
471
+ * @param {Number} [params.limit] - for paging
472
+ * @returns {resourceSelector} chains
473
+ * @fires resourceSelector#query
474
+ */
475
+ query: function query(params) {
476
+ var defaultParams;
477
+ var search;
478
+
479
+ if (this.is('rendered') && !this.is('loading')) {
480
+ this.setState('loading', true);
481
+ params = params || {};
482
+ search = this.getSearchQuery();
483
+ defaultParams = {
484
+ classUri: this.classUri,
485
+ format: this.format,
486
+ limit: this.config.limit,
487
+ search: _.isObject(search) ? JSON.stringify(search) : ''
488
+ };
489
+ /**
490
+ * Formulate the query
491
+ * @event resourceSelector#query
492
+ * @param {Object} params - see format above
493
+ */
457
494
 
458
- return this;
459
- },
495
+ this.trigger('query', _.defaults(params, defaultParams));
496
+ }
460
497
 
461
- /**
462
- * Clear the search query to submit
463
- * @returns {Object} the query
464
- */
465
- getSearchQuery: function getSearchQuery() {
466
- if (_.size(this.searchQuery) === 0) {
467
- this.searchQuery[labelUri] = '';
468
- }
498
+ return this;
499
+ },
469
500
 
470
- return this.searchQuery;
471
- },
472
-
473
- /**
474
- * Ask for a query (forward the event)
475
- * @param {Object} [params] - the query parameters
476
- * @param {String} [params.classUri] - the current node class URI
477
- * @param {String} [params.format] - the selected format
478
- * @param {String} [params.search] - the search query
479
- * @param {Number} [params.offset = 0] - for paging
480
- * @param {Number} [params.limit] - for paging
481
- * @returns {resourceSelector} chains
482
- * @fires resourceSelector#query
483
- */
484
- query: function query(params) {
485
- var defaultParams;
486
- var search;
487
-
488
- if (this.is('rendered') && !this.is('loading')) {
489
- this.setState('loading', true);
490
- params = params || {};
491
- search = this.getSearchQuery();
492
- defaultParams = {
493
- classUri: this.classUri,
494
- format: this.format,
495
- limit: this.config.limit,
496
- search: _.isObject(search) ? JSON.stringify(search) : ''
497
- };
501
+ /**
502
+ * Switch the format, so the viewer/selector component
503
+ * @param {String} format - the new format
504
+ * @returns {resourceSelector} chains
505
+ * @fires resourceSelector#formatchange
506
+ */
507
+ changeFormat: function changeFormat(format) {
508
+ var $viewFormat;
509
+
510
+ if (this.is('rendered') && this.format !== format) {
511
+ $viewFormat = $viewFormats.filter("[data-view-format=\"".concat(format, "\"]"));
512
+
513
+ if ($viewFormat.length === 1 && !$viewFormat.hasClass('active')) {
514
+ $viewFormats.removeClass('active');
515
+ $viewFormat.addClass('active');
516
+ this.empty();
517
+ this.format = format;
498
518
  /**
499
- * Formulate the query
500
- * @event resourceSelector#query
501
- * @param {Object} params - see format above
519
+ * The view format has changed
520
+ * @event resourceSelector#formatchange
521
+ * @param {String} format - the new format name
502
522
  */
503
523
 
504
- this.trigger('query', _.defaults(params, defaultParams));
524
+ this.trigger('formatchange', format);
505
525
  }
526
+ }
506
527
 
507
- return this;
508
- },
509
-
510
- /**
511
- * Switch the format, so the viewer/selector component
512
- * @param {String} format - the new format
513
- * @returns {resourceSelector} chains
514
- * @fires resourceSelector#formatchange
515
- */
516
- changeFormat: function changeFormat(format) {
517
- var $viewFormat;
518
-
519
- if (this.is('rendered') && this.format !== format) {
520
- $viewFormat = $viewFormats.filter(`[data-view-format="${format}"]`);
521
-
522
- if ($viewFormat.length === 1 && !$viewFormat.hasClass('active')) {
523
- $viewFormats.removeClass('active');
524
- $viewFormat.addClass('active');
525
- this.empty();
526
- this.format = format;
527
- /**
528
- * The view format has changed
529
- * @event resourceSelector#formatchange
530
- * @param {String} format - the new format name
531
- */
532
-
533
- this.trigger('formatchange', format);
534
- }
528
+ return this;
529
+ },
530
+
531
+ /**
532
+ * Let's you change the selection mode
533
+ * @param {String} newMode - single or multiple
534
+ * @returns {resourceSelector} chains
535
+ */
536
+ changeSelectionMode: function changeSelectionMode(newMode) {
537
+ if (this.is('rendered') && this.config.selectionMode !== newMode && selectionModes[newMode]) {
538
+ if (this.config.multiple) {
539
+ this.clearSelection();
535
540
  }
536
541
 
537
- return this;
538
- },
539
-
540
- /**
541
- * Let's you change the selection mode
542
- * @param {String} newMode - single or multiple
543
- * @returns {resourceSelector} chains
544
- */
545
- changeSelectionMode: function changeSelectionMode(newMode) {
546
- if (this.is('rendered') && this.config.selectionMode !== newMode && selectionModes[newMode]) {
547
- if (this.config.multiple) {
548
- this.clearSelection();
549
- }
542
+ this.config.multiple = newMode === selectionModes.multiple;
543
+ this.selectionComponent.setState('multiple', this.config.multiple);
544
+ this.setState('multiple', this.config.multiple);
550
545
 
551
- this.config.multiple = newMode === selectionModes.multiple;
552
- this.selectionComponent.setState('multiple', this.config.multiple);
553
- this.setState('multiple', this.config.multiple);
546
+ if (this.config.multiple) {
547
+ hider.show($selectCtrlLabel);
548
+ } else {
549
+ hider.hide($selectCtrlLabel);
550
+ }
551
+ /**
552
+ * The selection mode has changed
553
+ * @event resourceSelector#selectionmodechange
554
+ * @param {String} newMode - the new selection mode
555
+ */
554
556
 
555
- if (this.config.multiple) {
556
- hider.show($selectCtrlLabel);
557
- } else {
558
- hider.hide($selectCtrlLabel);
559
- }
560
- /**
561
- * The selection mode has changed
562
- * @event resourceSelector#selectionmodechange
563
- * @param {String} newMode - the new selection mode
564
- */
565
557
 
558
+ this.trigger('selectionmodechange', newMode);
559
+ }
566
560
 
567
- this.trigger('selectionmodechange', newMode);
568
- }
561
+ return this;
562
+ },
569
563
 
570
- return this;
571
- },
572
-
573
- /**
574
- * Update the component with the given resources
575
- * @param {Object[]} resources - the data, with at least a URI as key and as property
576
- * @param {Object} params - the query parameters
577
- * @returns {resourceSelector} chains
578
- * @fires resourceSelector#update
579
- * @fires resourceSelector#change
580
- * @fires resourceSelector#error
581
- */
582
- update: function update(resources, params) {
583
- var self = this;
584
- var componentFactory;
585
-
586
- if (this.is('rendered') && this.format) {
587
- componentFactory = this.config.formats[this.format] && this.config.formats[this.format].componentFactory;
588
-
589
- if (!_.isFunction(componentFactory)) {
590
- return this.trigger('error', new TypeError(`Unable to load the component for the format ${this.format}`));
591
- }
564
+ /**
565
+ * Update the component with the given resources
566
+ * @param {Object[]} resources - the data, with at least a URI as key and as property
567
+ * @param {Object} params - the query parameters
568
+ * @returns {resourceSelector} chains
569
+ * @fires resourceSelector#update
570
+ * @fires resourceSelector#change
571
+ * @fires resourceSelector#error
572
+ */
573
+ update: function update(resources, params) {
574
+ var self = this;
575
+ var componentFactory;
592
576
 
593
- hider.hide($noResults);
577
+ if (this.is('rendered') && this.format) {
578
+ componentFactory = this.config.formats[this.format] && this.config.formats[this.format].componentFactory;
594
579
 
595
- if (params.updateClasses && this.classSelector) {
596
- this.classSelector.updateNodes(filterClasses(resources));
597
- }
580
+ if (!_.isFunction(componentFactory)) {
581
+ return this.trigger('error', new TypeError("Unable to load the component for the format ".concat(this.format)));
582
+ }
598
583
 
599
- if (!this.selectionComponent) {
600
- this.selectionComponent = componentFactory($resultArea, _.defaults({
601
- classUri: this.classUri,
602
- nodes: resources
603
- }, this.config)).on('query', function (queryParams) {
604
- self.query(queryParams);
605
- }).on('update', function () {
606
- if (_.size(this.getNodes()) === 0 && $$1('li', $resultArea).length === 0) {
607
- hider.show($noResults);
608
- }
609
-
610
- self.trigger('update');
611
- }).on('change', function (selected, onlyVisible) {
612
- self.trigger('change', selected, onlyVisible);
613
- }).on('error', function (err) {
614
- self.trigger('error', err);
615
- });
616
- } else {
617
- this.selectionComponent.update(resources, params);
618
- }
584
+ hider.hide($noResults);
619
585
 
620
- this.setState('loading', false);
586
+ if (params.updateClasses && this.classSelector) {
587
+ this.classSelector.updateNodes(filterClasses(resources));
621
588
  }
622
589
 
623
- return this;
624
- },
625
-
626
- /**
627
- * Update the filters component
628
- * @param {Object?} filterConfig - the new filter configuration
629
- * @returns {resourceSelector} chains
630
- */
631
- updateFilters: function updateFilters(filterConfig) {
632
- if (this.is('rendered') && filterConfig !== false && this.filtersComponent) {
633
- this.filtersComponent.update(filterConfig);
590
+ if (!this.selectionComponent) {
591
+ this.selectionComponent = componentFactory($resultArea, _.defaults({
592
+ classUri: this.classUri,
593
+ nodes: resources
594
+ }, this.config)).on('query', function (queryParams) {
595
+ self.query(queryParams);
596
+ }).on('update', function () {
597
+ if (_.size(this.getNodes()) === 0 && $$1('li', $resultArea).length === 0) {
598
+ hider.show($noResults);
599
+ }
600
+
601
+ self.trigger('update');
602
+ }).on('change', function (selected, onlyVisible) {
603
+ self.trigger('change', selected, onlyVisible);
604
+ }).on('error', function (err) {
605
+ self.trigger('error', err);
606
+ });
607
+ } else {
608
+ this.selectionComponent.update(resources, params);
634
609
  }
635
610
 
636
- return this;
637
- },
638
-
639
- /**
640
- * Remove a given node, from the selection component and the node list.
641
- *
642
- * @param {Object|String} node - the node or the node URI
643
- * @param {String} [node.uri]
644
- * @returns {resourceSelector} chains
645
- */
646
- removeNode: function removeNode(node) {
647
- var uri = _.isString(node) ? node : node.uri;
648
-
649
- if (this.hasNode(uri)) {
650
- //update the class selector
651
- if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
652
- this.classSelector.removeNode(node);
653
- }
611
+ this.setState('loading', false);
612
+ }
654
613
 
655
- this.selectionComponent.removeNode(uri);
656
- }
614
+ return this;
615
+ },
657
616
 
658
- return this;
659
- },
660
-
661
- /**
662
- * Add manually a node.
663
- *
664
- * @param {Object} node - the node to add
665
- * @param {String} node.uri
666
- * @param {String} node.label
667
- * @param {String} [node.type=instance] - instance or class
668
- * @param {String} [parentUri] - where to append the new node
669
- * @returns {resourceSelector} chains
670
- */
671
- addNode: function addNode(node, parentUri) {
672
- if (this.is('rendered') && node && node.uri && this.selectionComponent) {
673
- if (!this.selectionComponent.hasNode(node.uri)) {
674
- if (!node.type) {
675
- node.type = nodeTypes.instance;
676
- } //update the selection component
677
-
678
-
679
- this.selectionComponent.update([node], {
680
- classUri: parentUri || this.classUri,
681
- format: this.format,
682
- limit: this.config.limit,
683
- updateCount: node.type === nodeTypes.instance ? 1 : false
684
- }); //update the class selector
685
-
686
- if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
687
- this.classSelector.addNode(node, parentUri);
688
- }
689
- }
617
+ /**
618
+ * Update the filters component
619
+ * @param {Object?} filterConfig - the new filter configuration
620
+ * @returns {resourceSelector} chains
621
+ */
622
+ updateFilters: function updateFilters(filterConfig) {
623
+ if (this.is('rendered') && filterConfig !== false && this.filtersComponent) {
624
+ this.filtersComponent.update(filterConfig);
625
+ }
626
+
627
+ return this;
628
+ },
629
+
630
+ /**
631
+ * Remove a given node, from the selection component and the node list.
632
+ *
633
+ * @param {Object|String} node - the node or the node URI
634
+ * @param {String} [node.uri]
635
+ * @returns {resourceSelector} chains
636
+ */
637
+ removeNode: function removeNode(node) {
638
+ var uri = _.isString(node) ? node : node.uri;
639
+
640
+ if (this.hasNode(uri)) {
641
+ //update the class selector
642
+ if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
643
+ this.classSelector.removeNode(node);
690
644
  }
691
645
 
692
- return this;
693
- },
694
-
695
- /**
696
- * Add class to classSelector, no update of selectionComponent
697
- *
698
- * @param {Object} node - the class node to add
699
- * @param {String} node.uri
700
- * @param {String} node.label
701
- * @param {String} parentUri - where to append the new node
702
- * @returns {resourceSelector} chains
703
- */
704
- addClassNode: function addClassNode(node, parentUri) {
705
- if (this.is('rendered') && node && node.uri && this.classSelector) {
706
- if (!this.classSelector.hasNode(node.uri) && this.classSelector.hasNode(parentUri)) {
707
- //add node to the class selector
646
+ this.selectionComponent.removeNode(uri);
647
+ }
648
+
649
+ return this;
650
+ },
651
+
652
+ /**
653
+ * Add manually a node.
654
+ *
655
+ * @param {Object} node - the node to add
656
+ * @param {String} node.uri
657
+ * @param {String} node.label
658
+ * @param {String} [node.type=instance] - instance or class
659
+ * @param {String} [parentUri] - where to append the new node
660
+ * @returns {resourceSelector} chains
661
+ */
662
+ addNode: function addNode(node, parentUri) {
663
+ if (this.is('rendered') && node && node.uri && this.selectionComponent) {
664
+ if (!this.selectionComponent.hasNode(node.uri)) {
665
+ if (!node.type) {
666
+ node.type = nodeTypes.instance;
667
+ } //update the selection component
668
+
669
+
670
+ this.selectionComponent.update([node], {
671
+ classUri: parentUri || this.classUri,
672
+ format: this.format,
673
+ limit: this.config.limit,
674
+ updateCount: node.type === nodeTypes.instance ? 1 : false
675
+ }); //update the class selector
676
+
677
+ if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
708
678
  this.classSelector.addNode(node, parentUri);
709
679
  }
710
680
  }
681
+ }
711
682
 
712
- return this;
713
- },
714
-
715
- /**
716
- * Does the given node exists ?
717
- *
718
- * @param {Object|String} node - the node or directly the URI
719
- * @param {String} [node.uri]
720
- * @returns {Boolean}
721
- */
722
- hasNode: function hasNode(node) {
723
- var uri;
724
-
725
- if (node && this.is('rendered') && this.selectionComponent) {
726
- uri = _.isString(node) ? node : node.uri;
727
- return this.selectionComponent.hasNode(uri);
728
- }
683
+ return this;
684
+ },
729
685
 
730
- return false;
731
- },
732
-
733
- /**
734
- * Get the type of a node, usually instance or class
735
- *
736
- * @param {Object|String} node - the node or directly the URI
737
- * @param {String} [node.uri]
738
- * @returns {String|Boolean} one of the nodeTypes or false
739
- */
740
- getNodeType: function getNodeType(node) {
741
- var uri;
742
- var foundNode;
743
-
744
- if (node && this.is('rendered') && this.selectionComponent) {
745
- uri = _.isString(node) ? node : node.uri;
746
- foundNode = this.selectionComponent.getNode(uri);
747
- return foundNode && foundNode.type;
686
+ /**
687
+ * Add class to classSelector, no update of selectionComponent
688
+ *
689
+ * @param {Object} node - the class node to add
690
+ * @param {String} node.uri
691
+ * @param {String} node.label
692
+ * @param {String} parentUri - where to append the new node
693
+ * @returns {resourceSelector} chains
694
+ */
695
+ addClassNode: function addClassNode(node, parentUri) {
696
+ if (this.is('rendered') && node && node.uri && this.classSelector) {
697
+ if (!this.classSelector.hasNode(node.uri) && this.classSelector.hasNode(parentUri)) {
698
+ //add node to the class selector
699
+ this.classSelector.addNode(node, parentUri);
748
700
  }
701
+ }
749
702
 
750
- return false;
751
- },
752
-
753
- /**
754
- * Select a node manually
755
- *
756
- * @param {Object|String} node - the node to select or directly the URI
757
- * @param {String} [node.uri]
758
- * @returns {resourceSelector} chains
759
- */
760
- select: function select(node) {
761
- var uri = _.isString(node) ? node : node.uri;
762
-
763
- if (this.hasNode(uri)) {
764
- if (!this.is('multiple')) {
765
- this.selectionComponent.clearSelection();
766
- }
703
+ return this;
704
+ },
767
705
 
768
- this.selectionComponent.select(uri);
769
- $$1(`[data-uri="${uri}"]`, $resultArea)[0].scrollIntoView({
770
- behavior: 'smooth'
771
- });
772
- }
706
+ /**
707
+ * Does the given node exists ?
708
+ *
709
+ * @param {Object|String} node - the node or directly the URI
710
+ * @param {String} [node.uri]
711
+ * @returns {Boolean}
712
+ */
713
+ hasNode: function hasNode(node) {
714
+ var uri;
773
715
 
774
- return this;
775
- },
776
-
777
- /**
778
- * Select the default node, then fallback to 1st instance then 1st class
779
- *
780
- * @param {Object|String} node - the node to select or directly the URI
781
- * @param {String} [node.uri]
782
- * @param {Boolean} [fallback=true] - apply the fallback ?
783
- * @returns {resourceSelector} chains
784
- */
785
- selectDefaultNode: function selectDefaultNode(node, fallback) {
786
- var $resource;
787
-
788
- if (this.is('rendered')) {
789
- if (this.hasNode(node)) {
790
- this.select(node);
791
- } else if (fallback !== false) {
792
- $resource = this.getElement().find(`.${nodeTypes.instance}`);
793
-
794
- if (!$resource.length) {
795
- $resource = this.getElement().find(`.${nodeTypes.class}`);
796
- }
716
+ if (node && this.is('rendered') && this.selectionComponent) {
717
+ uri = _.isString(node) ? node : node.uri;
718
+ return this.selectionComponent.hasNode(uri);
719
+ }
797
720
 
798
- if ($resource.length) {
799
- this.select($resource.first().data('uri'));
800
- }
801
- }
802
- }
721
+ return false;
722
+ },
803
723
 
804
- return this;
805
- },
806
-
807
- /**
808
- * Refresh and select the given node
809
- *
810
- * @param {Object|String} node - the node to select or directly the URI
811
- * @param {String} [node.uri]
812
- * @returns {resourceSelector} chains
813
- */
814
- refresh: function refresh(node) {
815
- var queryParams = {
816
- updateClasses: true
817
- };
724
+ /**
725
+ * Get the type of a node, usually instance or class
726
+ *
727
+ * @param {Object|String} node - the node or directly the URI
728
+ * @param {String} [node.uri]
729
+ * @returns {String|Boolean} one of the nodeTypes or false
730
+ */
731
+ getNodeType: function getNodeType(node) {
732
+ var uri;
733
+ var foundNode;
734
+
735
+ if (node && this.is('rendered') && this.selectionComponent) {
736
+ uri = _.isString(node) ? node : node.uri;
737
+ foundNode = this.selectionComponent.getNode(uri);
738
+ return foundNode && foundNode.type;
739
+ }
818
740
 
819
- if (this.is('rendered')) {
820
- this.on('update.refresh', function () {
821
- this.off('update.refresh');
822
- this.selectDefaultNode(node);
823
- });
741
+ return false;
742
+ },
824
743
 
825
- if (node && node.uri) {
826
- queryParams.selectedUri = node.uri;
827
- }
744
+ /**
745
+ * Select a node manually
746
+ *
747
+ * @param {Object|String} node - the node to select or directly the URI
748
+ * @param {String} [node.uri]
749
+ * @returns {resourceSelector} chains
750
+ */
751
+ select: function select(node) {
752
+ var uri = _.isString(node) ? node : node.uri;
828
753
 
829
- this.reset().query(queryParams);
754
+ if (this.hasNode(uri)) {
755
+ if (!this.is('multiple')) {
756
+ this.selectionComponent.clearSelection();
830
757
  }
831
758
 
832
- return this;
759
+ this.selectionComponent.select(uri);
760
+ $$1("[data-uri=\"".concat(uri, "\"]"), $resultArea)[0].scrollIntoView({
761
+ behavior: 'smooth'
762
+ });
833
763
  }
834
- };
764
+
765
+ return this;
766
+ },
767
+
835
768
  /**
836
- * The resource selector component
837
- * @typedef {ui/component} resourceSelector
769
+ * Select the default node, then fallback to 1st instance then 1st class
770
+ *
771
+ * @param {Object|String} node - the node to select or directly the URI
772
+ * @param {String} [node.uri]
773
+ * @param {Boolean} [fallback=true] - apply the fallback ?
774
+ * @returns {resourceSelector} chains
838
775
  */
776
+ selectDefaultNode: function selectDefaultNode(node, fallback) {
777
+ var $resource;
839
778
 
840
- var resourceSelector = component(resourceSelectorApi, defaultConfig).setTemplate(selectorTpl).on('init', function () {
841
- this.searchQuery = {};
842
- this.classUri = this.config.classUri;
843
- this.format = this.config.format || _.findKey(this.config.formats, {
844
- active: true
845
- });
846
- this.config.switchMode = this.config.selectionMode === selectionModes.both;
847
- this.config.multiple = this.config.selectionMode === selectionModes.multiple;
848
- this.setState('multiple', this.config.multiple);
849
- this.render($container);
850
- }).on('render', function () {
851
- var self = this; //we ensure the sub-components are rendered
852
-
853
- return new Promise(function (resolve) {
854
- var $component = self.getElement();
855
- $classContainer = $$1('.class-context', $component);
856
- $resultArea = $$1('main', $component);
857
- $noResults = $$1('.no-results', $resultArea);
858
- $searchField = $$1('.search input', $component);
859
- $filterToggle = $$1('.filters-opener', $component);
860
- $filterContainer = $$1('.filters-container', $component);
861
- $viewFormats = $$1('.context > a', $component);
862
- $selectNum = $$1('.selected-num', $component);
863
- $selectCtrl = $$1('.selection-control input', $component);
864
- $selectCtrlLabel = $$1('.selection-control label', $component);
865
- $selectionToggle = $$1('.selection-toggle', $component); //the search field
866
-
867
- $searchField.on('keyup', _.debounce(function (e) {
868
- var value = $$1(this).val().trim();
869
-
870
- if (value.length > 2 || value.length === 0 || e.which === 13) {
871
- if (self.config.filters) {
872
- //reset the placeholder
873
- $$1(this).attr('title', null).attr('placeholder', self.config.searchPlaceholder);
874
- }
779
+ if (this.is('rendered')) {
780
+ if (this.hasNode(node)) {
781
+ this.select(node);
782
+ } else if (fallback !== false) {
783
+ $resource = this.getElement().find(".".concat(nodeTypes.instance));
875
784
 
876
- self.empty().changeFormat('list').setSearchQuery(value).query();
785
+ if (!$resource.length) {
786
+ $resource = this.getElement().find(".".concat(nodeTypes.class));
877
787
  }
878
- }, 300)); //the format switcher
879
788
 
880
- $viewFormats.on('click', function (e) {
881
- var $target = $$1(this);
882
- var format = $target.data('view-format');
883
- e.preventDefault();
884
- self.reset().changeFormat(format).query();
885
- }); //mode switcher (multiple/single)
886
-
887
- if (self.config.selectionMode === selectionModes.both) {
888
- //click the toggler
889
- $selectionToggle.on('click', function (e) {
890
- e.preventDefault();
891
- self.changeSelectionMode(self.config.multiple ? selectionModes.single : selectionModes.multiple);
892
- }); //CTRL-Click
893
-
894
- $resultArea.on('mousedown', function (e) {
895
- if (e.ctrlKey && !self.config.multiple) {
896
- self.changeSelectionMode(selectionModes.multiple);
897
- }
898
- }); //switch back to sinlge
789
+ if ($resource.length) {
790
+ this.select($resource.first().data('uri'));
791
+ }
792
+ }
793
+ }
899
794
 
900
- $resultArea.on('click', function () {
901
- self.changeSelectionMode(selectionModes.single);
902
- });
903
- } //the select all control
795
+ return this;
796
+ },
904
797
 
798
+ /**
799
+ * Refresh and select the given node
800
+ *
801
+ * @param {Object|String} node - the node to select or directly the URI
802
+ * @param {String} [node.uri]
803
+ * @returns {resourceSelector} chains
804
+ */
805
+ refresh: function refresh(node) {
806
+ var queryParams = {
807
+ updateClasses: true
808
+ };
809
+
810
+ if (this.is('rendered')) {
811
+ this.on('update.refresh', function () {
812
+ this.off('update.refresh');
813
+ this.selectDefaultNode(node);
814
+ });
815
+
816
+ if (node && node.uri) {
817
+ queryParams.selectedUri = node.uri;
818
+ }
819
+
820
+ this.reset().query(queryParams);
821
+ }
905
822
 
906
- $selectCtrl.on('change', function () {
907
- if ($$1(this).prop('checked') === false) {
908
- self.selectionComponent.clearSelection();
909
- } else if (self.config.selectAllPolicy === selectAllPolicies.visible) {
910
- self.selectionComponent.selectVisible();
911
- } else if (self.config.selectAllPolicy === selectAllPolicies.loaded) {
912
- self.selectionComponent.selectAll();
823
+ return this;
824
+ }
825
+ };
826
+ /**
827
+ * The resource selector component
828
+ * @typedef {ui/component} resourceSelector
829
+ */
830
+
831
+ var resourceSelector = component(resourceSelectorApi, defaultConfig).setTemplate(selectorTpl).on('init', function () {
832
+ this.searchQuery = {};
833
+ this.classUri = this.config.classUri;
834
+ this.format = this.config.format || _.findKey(this.config.formats, {
835
+ active: true
836
+ });
837
+ this.config.switchMode = this.config.selectionMode === selectionModes.both;
838
+ this.config.multiple = this.config.selectionMode === selectionModes.multiple;
839
+ this.setState('multiple', this.config.multiple);
840
+ this.render($container);
841
+ }).on('render', function () {
842
+ var self = this; //we ensure the sub-components are rendered
843
+
844
+ return new Promise(function (resolve) {
845
+ var $component = self.getElement();
846
+ $classContainer = $$1('.class-context', $component);
847
+ $resultArea = $$1('main', $component);
848
+ $noResults = $$1('.no-results', $resultArea);
849
+ $searchField = $$1('.search input', $component);
850
+ $filterToggle = $$1('.filters-opener', $component);
851
+ $filterContainer = $$1('.filters-container', $component);
852
+ $viewFormats = $$1('.context > a', $component);
853
+ $selectNum = $$1('.selected-num', $component);
854
+ $selectCtrl = $$1('.selection-control input', $component);
855
+ $selectCtrlLabel = $$1('.selection-control label', $component);
856
+ $selectionToggle = $$1('.selection-toggle', $component); //the search field
857
+
858
+ $searchField.on('keyup', _.debounce(function (e) {
859
+ var value = $$1(this).val().trim();
860
+
861
+ if (value.length > 2 || value.length === 0 || e.which === 13) {
862
+ if (self.config.filters) {
863
+ //reset the placeholder
864
+ $$1(this).attr('title', null).attr('placeholder', self.config.searchPlaceholder);
913
865
  }
914
- }); //the advanced filters
915
-
916
- if (self.config.filters !== false) {
917
- self.filtersComponent = filtersFactory($filterContainer, {
918
- classUri: self.classUri,
919
- data: self.config.filters
920
- }).on('change', function (values) {
921
- var textualQuery = this.getTextualQuery();
922
- $searchField.val('').attr('title', textualQuery).attr('placeholder', textualQuery);
923
- self.empty().changeFormat('list').setSearchQuery(values).query();
924
- $filterContainer.addClass('folded');
925
- });
926
- $filterToggle.on('click', function (e) {
927
- var searchVal;
928
- e.preventDefault();
929
866
 
930
- if ($filterContainer.hasClass('folded')) {
931
- //if a value is in the search field, we add it to the label
932
- searchVal = $searchField.val().trim();
867
+ self.empty().changeFormat('list').setSearchQuery(value).query();
868
+ }
869
+ }, 300)); //the format switcher
870
+
871
+ $viewFormats.on('click', function (e) {
872
+ var $target = $$1(this);
873
+ var format = $target.data('view-format');
874
+ e.preventDefault();
875
+ self.reset().changeFormat(format).query();
876
+ }); //mode switcher (multiple/single)
877
+
878
+ if (self.config.selectionMode === selectionModes.both) {
879
+ //click the toggler
880
+ $selectionToggle.on('click', function (e) {
881
+ e.preventDefault();
882
+ self.changeSelectionMode(self.config.multiple ? selectionModes.single : selectionModes.multiple);
883
+ }); //CTRL-Click
933
884
 
934
- if (!_.isEmpty(searchVal)) {
935
- self.filtersComponent.setValue(labelUri, searchVal);
936
- }
885
+ $resultArea.on('mousedown', function (e) {
886
+ if (e.ctrlKey && !self.config.multiple) {
887
+ self.changeSelectionMode(selectionModes.multiple);
888
+ }
889
+ }); //switch back to sinlge
937
890
 
938
- $filterContainer.removeClass('folded');
939
- } else {
940
- $filterContainer.addClass('folded');
941
- }
942
- });
943
- } //initialize the class selector
891
+ $resultArea.on('click', function () {
892
+ self.changeSelectionMode(selectionModes.single);
893
+ });
894
+ } //the select all control
944
895
 
945
896
 
946
- self.classSelector = classesSelectorFactory($classContainer, self.config);
947
- self.classSelector.on('render', resolve).on('change', function (uri) {
948
- if (uri && uri !== self.classUri) {
949
- self.classUri = uri; //close the filters
897
+ $selectCtrl.on('change', function () {
898
+ if ($$1(this).prop('checked') === false) {
899
+ self.selectionComponent.clearSelection();
900
+ } else if (self.config.selectAllPolicy === selectAllPolicies.visible) {
901
+ self.selectionComponent.selectVisible();
902
+ } else if (self.config.selectAllPolicy === selectAllPolicies.loaded) {
903
+ self.selectionComponent.selectAll();
904
+ }
905
+ }); //the advanced filters
906
+
907
+ if (self.config.filters !== false) {
908
+ self.filtersComponent = filtersFactory($filterContainer, {
909
+ classUri: self.classUri,
910
+ data: self.config.filters
911
+ }).on('change', function (values) {
912
+ var textualQuery = this.getTextualQuery();
913
+ $searchField.val('').attr('title', textualQuery).attr('placeholder', textualQuery);
914
+ self.empty().changeFormat('list').setSearchQuery(values).query();
915
+ $filterContainer.addClass('folded');
916
+ });
917
+ $filterToggle.on('click', function (e) {
918
+ var searchVal;
919
+ e.preventDefault();
950
920
 
951
- if ($filterContainer.length) {
952
- $filterContainer.addClass('folded');
953
- }
954
- /**
955
- * When the component's root class URI changes
956
- * @event resourceSelector#classchange
957
- * @param {String} classUri - the new class URI
958
- */
921
+ if ($filterContainer.hasClass('folded')) {
922
+ //if a value is in the search field, we add it to the label
923
+ searchVal = $searchField.val().trim();
959
924
 
925
+ if (!_.isEmpty(searchVal)) {
926
+ self.filtersComponent.setValue(labelUri, searchVal);
927
+ }
960
928
 
961
- self.trigger('classchange', uri);
962
- self.reset().query();
929
+ $filterContainer.removeClass('folded');
930
+ } else {
931
+ $filterContainer.addClass('folded');
963
932
  }
964
933
  });
965
- self.query();
966
- });
967
- }).on('change', function (selected, onlyVisible) {
968
- var selectedCount = _.size(selected);
934
+ } //initialize the class selector
969
935
 
970
- var nodesCount = onlyVisible ? selectedCount : _.size(this.selectionComponent.getNodes()); //the number selected at the bottom
971
936
 
972
- $selectNum.text(selectedCount); //update the state of the "Select All" checkbox
937
+ self.classSelector = classesSelectorFactory($classContainer, self.config);
938
+ self.classSelector.on('render', resolve).on('change', function (uri) {
939
+ if (uri && uri !== self.classUri) {
940
+ self.classUri = uri; //close the filters
941
+
942
+ if ($filterContainer.length) {
943
+ $filterContainer.addClass('folded');
944
+ }
945
+ /**
946
+ * When the component's root class URI changes
947
+ * @event resourceSelector#classchange
948
+ * @param {String} classUri - the new class URI
949
+ */
973
950
 
974
- if (selectedCount === 0) {
975
- $selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
976
- $selectCtrl.prop('checked', false).prop('indeterminate', false); // if all of the nodes are selected (or more in the closed subclasses)
977
- } else if (selectedCount >= nodesCount) {
978
- $selectCtrlLabel.attr('title', __('Clear selection'));
979
- $selectCtrl.prop('checked', true).prop('indeterminate', false);
980
- } else {
981
- $selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
982
- $selectCtrl.prop('checked', false).prop('indeterminate', true);
983
- }
984
- });
985
951
 
986
- _.defer(function () {
987
- resourceSelector.init(config);
952
+ self.trigger('classchange', uri);
953
+ self.reset().query();
954
+ }
955
+ });
956
+ self.query();
988
957
  });
958
+ }).on('change', function (selected, onlyVisible) {
959
+ var selectedCount = _.size(selected);
960
+
961
+ var nodesCount = onlyVisible ? selectedCount : _.size(this.selectionComponent.getNodes()); //the number selected at the bottom
962
+
963
+ $selectNum.text(selectedCount); //update the state of the "Select All" checkbox
964
+
965
+ if (selectedCount === 0) {
966
+ $selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
967
+ $selectCtrl.prop('checked', false).prop('indeterminate', false); // if all of the nodes are selected (or more in the closed subclasses)
968
+ } else if (selectedCount >= nodesCount) {
969
+ $selectCtrlLabel.attr('title', __('Clear selection'));
970
+ $selectCtrl.prop('checked', true).prop('indeterminate', false);
971
+ } else {
972
+ $selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
973
+ $selectCtrl.prop('checked', false).prop('indeterminate', true);
974
+ }
975
+ });
976
+
977
+ _.defer(function () {
978
+ resourceSelector.init(config);
979
+ });
989
980
 
990
- return resourceSelector;
991
- }; //Exposes the selection modes
981
+ return resourceSelector;
982
+ }; //Exposes the selection modes
992
983
 
993
984
 
994
- resourceSelectorFactory.selectionModes = selectionModes; //Exposes the selectAllPolicies
985
+ resourceSelectorFactory.selectionModes = selectionModes; //Exposes the selectAllPolicies
995
986
 
996
- resourceSelectorFactory.selectAllPolicies = selectAllPolicies; //Exposes the node types
987
+ resourceSelectorFactory.selectAllPolicies = selectAllPolicies; //Exposes the node types
997
988
 
998
- resourceSelectorFactory.nodeTypes = nodeTypes;
989
+ resourceSelectorFactory.nodeTypes = nodeTypes;
999
990
 
1000
- return resourceSelectorFactory;
991
+ return resourceSelectorFactory;
1001
992
 
1002
993
  });