@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,691 +1,690 @@
1
1
  define(['jquery', 'lodash', 'interact', 'ui/component', 'ui/component/stackable', 'ui/transformer', 'ui/interactUtils', 'util/position', 'lib/uuid', 'handlebars', 'i18n', 'lib/dompurify/purify', 'css!ui/dynamicComponent/css/dynamicComponent.css'], function ($$1, _, interact, componentFactory, makeStackable, transformer, interactUtils, position, uuid, Handlebars, __, DOMPurify, dynamicComponent_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
- interact = interact && Object.prototype.hasOwnProperty.call(interact, 'default') ? interact['default'] : interact;
6
- componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
7
- makeStackable = makeStackable && Object.prototype.hasOwnProperty.call(makeStackable, 'default') ? makeStackable['default'] : makeStackable;
8
- interactUtils = interactUtils && Object.prototype.hasOwnProperty.call(interactUtils, 'default') ? interactUtils['default'] : interactUtils;
9
- position = position && Object.prototype.hasOwnProperty.call(position, 'default') ? position['default'] : position;
10
- uuid = uuid && Object.prototype.hasOwnProperty.call(uuid, 'default') ? uuid['default'] : uuid;
11
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
12
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
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
+ interact = interact && Object.prototype.hasOwnProperty.call(interact, 'default') ? interact['default'] : interact;
6
+ componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
7
+ makeStackable = makeStackable && Object.prototype.hasOwnProperty.call(makeStackable, 'default') ? makeStackable['default'] : makeStackable;
8
+ interactUtils = interactUtils && Object.prototype.hasOwnProperty.call(interactUtils, 'default') ? interactUtils['default'] : interactUtils;
9
+ position = position && Object.prototype.hasOwnProperty.call(position, 'default') ? position['default'] : position;
10
+ uuid = uuid && Object.prototype.hasOwnProperty.call(uuid, 'default') ? uuid['default'] : uuid;
11
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
12
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
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
- */
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
+ */
58
49
 
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 : '"';
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 : '"';
64
55
 
65
- _.forIn(arr, function (value, key) {
66
- var fragment = '';
56
+ _.forIn(arr, function (value, key) {
57
+ var fragment = '';
67
58
 
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 = '';
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(' ');
76
64
  }
65
+ } else {
66
+ value = '';
67
+ }
77
68
 
78
- if (keyValueGlue !== undefined) {
79
- fragment += key + keyValueGlue;
80
- }
69
+ if (keyValueGlue !== undefined) {
70
+ fragment += key + keyValueGlue;
71
+ }
81
72
 
82
- fragment += wrapper + value + wrapper;
83
- fragments.push(fragment);
84
- });
73
+ fragment += wrapper + value + wrapper;
74
+ fragments.push(fragment);
75
+ });
85
76
 
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
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
89
80
 
90
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
91
- var ret = '';
92
- startIndex = parseInt(startIndex);
93
- stopIndex = parseInt(stopIndex);
94
- increment = parseInt(increment);
81
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
82
+ var ret = '';
83
+ startIndex = parseInt(startIndex);
84
+ stopIndex = parseInt(stopIndex);
85
+ increment = parseInt(increment);
95
86
 
96
- for (var i = startIndex; i < stopIndex; i += increment) {
97
- ret += options.fn(_.extend({}, this, {
98
- i: i
99
- }));
100
- }
87
+ for (var i = startIndex; i < stopIndex; i += increment) {
88
+ ret += options.fn(_.extend({}, this, {
89
+ i: i
90
+ }));
91
+ }
101
92
 
102
- return ret;
103
- });
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
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);
100
+ }
101
+ }); // register a "get property" helper
102
+ // it gets the named property from the provided context
112
103
 
113
- hb.registerHelper('property', function (name, context) {
114
- return context[name] || '';
115
- }); // register an 'includes' helper
116
- // it checks if value is in array
104
+ hb.registerHelper('property', function (name, context) {
105
+ return context[name] || '';
106
+ }); // register an 'includes' helper
107
+ // it checks if value is in array
117
108
 
118
- hb.registerHelper('includes', function (haystack, needle, options) {
119
- if (_.contains(haystack, needle)) {
120
- return options.fn(this);
121
- }
122
- });
109
+ hb.registerHelper('includes', function (haystack, needle, options) {
110
+ if (_.contains(haystack, needle)) {
111
+ return options.fn(this);
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, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
124
+
125
+ function program1(depth0,data) {
126
+
127
+
128
+ return "\n <div class=\"dynamic-component-layer\"></div>\n ";
123
129
  }
124
130
 
125
- if (!Helpers0.__initialized) {
126
- Helpers0(Handlebars);
127
- Helpers0.__initialized = true;
131
+ function program3(depth0,data) {
132
+
133
+
134
+ return "\n <div class=\"dynamic-component-resize-container\">\n <div class=\"dynamic-component-resize-wrapper\">\n <div class=\"dynamic-component-resize\"></div>\n </div>\n </div>\n ";
128
135
  }
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, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
133
-
134
- function program1(depth0,data) {
135
-
136
-
137
- return "\n <div class=\"dynamic-component-layer\"></div>\n ";
138
- }
139
136
 
140
- function program3(depth0,data) {
141
-
142
-
143
- return "\n <div class=\"dynamic-component-resize-container\">\n <div class=\"dynamic-component-resize-wrapper\">\n <div class=\"dynamic-component-resize\"></div>\n </div>\n </div>\n ";
137
+ buffer += "<div class=\"dynamic-component-container\">\n <div class=\"dynamic-component-title-bar\">\n <i class=\"title-bar-icon\"></i>\n <a title=\""
138
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Close", options) : helperMissing.call(depth0, "__", "Close", options)))
139
+ + "\" class=\"closer\" href=\"#\"></a>\n </div>\n <div class=\"dynamic-component-content\">\n ";
140
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.draggableContainer), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
141
+ if(stack1 || stack1 === 0) { buffer += stack1; }
142
+ buffer += "\n </div>\n ";
143
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.resizable), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
144
+ if(stack1 || stack1 === 0) { buffer += stack1; }
145
+ buffer += "\n</div>";
146
+ return buffer;
147
+ });
148
+ function layoutTpl(data, options, asString) {
149
+ var html = Template(data, options);
150
+ return (asString || true) ? html : $(html);
151
+ }
152
+
153
+ /**
154
+ * This program is free software; you can redistribute it and/or
155
+ * modify it under the terms of the GNU General Public License
156
+ * as published by the Free Software Foundation; under version 2
157
+ * of the License (non-upgradable).
158
+ *
159
+ * This program is distributed in the hope that it will be useful,
160
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
161
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
162
+ * GNU General Public License for more details.
163
+ *
164
+ * You should have received a copy of the GNU General Public License
165
+ * along with this program; if not, write to the Free Software
166
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
167
+ *
168
+ * Copyright (c) 2016-2019 (original work) Open Assessment Technologies SA ;
169
+ */
170
+ var _defaults = {
171
+ resizable: true,
172
+ draggable: true,
173
+ width: 240,
174
+ height: 360,
175
+ minWidth: 150,
176
+ maxWidth: 600,
177
+ minHeight: 100,
178
+ maxHeight: 900,
179
+ largeWidthThreshold: 380,
180
+ smallWidthThreshold: 200,
181
+ draggableContainer: 'parent',
182
+ preserveAspectRatio: true,
183
+ top: 0,
184
+ left: 0,
185
+ proportionalResize: false
186
+ };
187
+ /**
188
+ * Defines a dynamicComponent
189
+ * @typedef {Object} dynamicComponent
190
+ */
191
+
192
+ var dynamicComponent = {
193
+ /**
194
+ * Reset the position and the size
195
+ * @returns {dynamicComponent} chains
196
+ * @fires dynamicComponent#reset
197
+ */
198
+ reset: function reset() {
199
+ if (this.is('rendered') && !this.is('disabled')) {
200
+ this.resetPosition();
201
+ this.resetSize();
202
+ /**
203
+ * @event dynamicComponent#reset
204
+ */
205
+
206
+ this.trigger('reset');
144
207
  }
145
208
 
146
- buffer += "<div class=\"dynamic-component-container\">\n <div class=\"dynamic-component-title-bar\">\n <i class=\"title-bar-icon\"></i>\n <a title=\""
147
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Close", options) : helperMissing.call(depth0, "__", "Close", options)))
148
- + "\" class=\"closer\" href=\"#\"></a>\n </div>\n <div class=\"dynamic-component-content\">\n ";
149
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.draggableContainer), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
150
- if(stack1 || stack1 === 0) { buffer += stack1; }
151
- buffer += "\n </div>\n ";
152
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.resizable), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
153
- if(stack1 || stack1 === 0) { buffer += stack1; }
154
- buffer += "\n</div>";
155
- return buffer;
156
- });
157
- function layoutTpl(data, options, asString) {
158
- var html = Template(data, options);
159
- return (asString || true) ? html : $(html);
160
- }
209
+ return this;
210
+ },
161
211
 
162
212
  /**
163
- * This program is free software; you can redistribute it and/or
164
- * modify it under the terms of the GNU General Public License
165
- * as published by the Free Software Foundation; under version 2
166
- * of the License (non-upgradable).
167
- *
168
- * This program is distributed in the hope that it will be useful,
169
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
170
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171
- * GNU General Public License for more details.
172
- *
173
- * You should have received a copy of the GNU General Public License
174
- * along with this program; if not, write to the Free Software
175
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
176
- *
177
- * Copyright (c) 2016-2019 (original work) Open Assessment Technologies SA ;
213
+ * Reset the component position to it's original value
214
+ * @returns {dynamicComponent} chains
215
+ * @fires dynamicComponent#move
178
216
  */
179
- var _defaults = {
180
- resizable: true,
181
- draggable: true,
182
- width: 240,
183
- height: 360,
184
- minWidth: 150,
185
- maxWidth: 600,
186
- minHeight: 100,
187
- maxHeight: 900,
188
- largeWidthThreshold: 380,
189
- smallWidthThreshold: 200,
190
- draggableContainer: 'parent',
191
- preserveAspectRatio: true,
192
- top: 0,
193
- left: 0,
194
- proportionalResize: false
195
- };
217
+ resetPosition: function resetPosition() {
218
+ var $element = this.getElement();
219
+
220
+ if (this.is('rendered') && !this.is('disabled')) {
221
+ interactUtils.restoreOriginalPosition($element);
222
+ this.setCoords();
223
+ $element.css({
224
+ left: this.config.left,
225
+ top: this.config.top
226
+ });
227
+ /**
228
+ * @event dynamicComponent#move
229
+ * @param {Object} position - the new positions
230
+ */
231
+
232
+ this.trigger('move', this.position);
233
+ }
234
+
235
+ return this;
236
+ },
237
+
196
238
  /**
197
- * Defines a dynamicComponent
198
- * @typedef {Object} dynamicComponent
239
+ * compute x/y coords of the component according to the start position and the dragged offset
199
240
  */
241
+ setCoords: function setCoords() {
242
+ var $element = this.getElement(); // fixme: attributes data-x and data-y are added by interactUtils.
243
+ // If the position is really needed, it should be computed differently
200
244
 
201
- var dynamicComponent = {
202
- /**
203
- * Reset the position and the size
204
- * @returns {dynamicComponent} chains
205
- * @fires dynamicComponent#reset
206
- */
207
- reset: function reset() {
208
- if (this.is('rendered') && !this.is('disabled')) {
209
- this.resetPosition();
210
- this.resetSize();
211
- /**
212
- * @event dynamicComponent#reset
213
- */
214
-
215
- this.trigger('reset');
216
- }
245
+ this.position.x = parseFloat($element.attr('data-x')) + this.config.left;
246
+ this.position.y = parseFloat($element.attr('data-y')) + this.config.top;
247
+ },
217
248
 
218
- return this;
219
- },
249
+ /**
250
+ * Sets the size of the content, and adapts the component's size accordingly.
251
+ * @param {Number} width - The width of the content, the full width of the component will be adjusted.
252
+ * @param {Number} height - The height of the content, the full height of the component will be adjusted.
253
+ * @returns {dynamicComponent} chains
254
+ * @fires dynamicComponent#resize
255
+ */
256
+ setContentSize: function setContentSize(width, height) {
257
+ var $element, $titleBar;
258
+
259
+ if (this.is('rendered') && !this.is('disabled')) {
260
+ $element = this.getElement();
261
+ $titleBar = $$1('.dynamic-component-title-bar', $element);
262
+ this.config.width = width + $element.outerWidth() - $element.width();
263
+ this.config.height = height + $element.outerHeight() - $element.height() + $titleBar.outerHeight();
264
+ this.resetSize();
265
+ }
220
266
 
221
- /**
222
- * Reset the component position to it's original value
223
- * @returns {dynamicComponent} chains
224
- * @fires dynamicComponent#move
225
- */
226
- resetPosition: function resetPosition() {
227
- var $element = this.getElement();
267
+ return this;
268
+ },
228
269
 
229
- if (this.is('rendered') && !this.is('disabled')) {
230
- interactUtils.restoreOriginalPosition($element);
231
- this.setCoords();
232
- $element.css({
233
- left: this.config.left,
234
- top: this.config.top
270
+ /**
271
+ * Reset the component size to it's original value
272
+ * @returns {dynamicComponent} chains
273
+ * @fires dynamicComponent#resize
274
+ */
275
+ resetSize: function resetSize() {
276
+ var self = this;
277
+ var $element;
278
+ var $content;
279
+ var $titleBar;
280
+
281
+ if (this.is('rendered') && !this.is('disabled')) {
282
+ $element = this.getElement();
283
+ $content = $$1('.dynamic-component-content', $element);
284
+ $titleBar = $$1('.dynamic-component-title-bar', $element);
285
+ $element.css({
286
+ width: this.config.width + 'px',
287
+ height: this.config.height + 'px'
288
+ }); //defer to ensure the next reflow occurs before calculating the content size
289
+
290
+ _.defer(function () {
291
+ self.position.width = self.config.width;
292
+ self.position.height = self.config.height;
293
+ self.position.contentWidth = $titleBar.width();
294
+ self.position.contentHeight = $element.height() - $titleBar.outerHeight();
295
+ $content.css({
296
+ width: self.position.contentWidth + 'px',
297
+ height: self.position.contentHeight + 'px'
235
298
  });
236
299
  /**
237
- * @event dynamicComponent#move
300
+ * @event dynamicComponent#resize
238
301
  * @param {Object} position - the new positions
239
302
  */
240
303
 
241
- this.trigger('move', this.position);
242
- }
243
-
244
- return this;
245
- },
246
-
247
- /**
248
- * compute x/y coords of the component according to the start position and the dragged offset
249
- */
250
- setCoords: function setCoords() {
251
- var $element = this.getElement(); // fixme: attributes data-x and data-y are added by interactUtils.
252
- // If the position is really needed, it should be computed differently
253
-
254
- this.position.x = parseFloat($element.attr('data-x')) + this.config.left;
255
- this.position.y = parseFloat($element.attr('data-y')) + this.config.top;
256
- },
257
-
258
- /**
259
- * Sets the size of the content, and adapts the component's size accordingly.
260
- * @param {Number} width - The width of the content, the full width of the component will be adjusted.
261
- * @param {Number} height - The height of the content, the full height of the component will be adjusted.
262
- * @returns {dynamicComponent} chains
263
- * @fires dynamicComponent#resize
264
- */
265
- setContentSize: function setContentSize(width, height) {
266
- var $element, $titleBar;
267
-
268
- if (this.is('rendered') && !this.is('disabled')) {
269
- $element = this.getElement();
270
- $titleBar = $$1('.dynamic-component-title-bar', $element);
271
- this.config.width = width + $element.outerWidth() - $element.width();
272
- this.config.height = height + $element.outerHeight() - $element.height() + $titleBar.outerHeight();
273
- this.resetSize();
274
- }
275
-
276
- return this;
277
- },
304
+ self.trigger('resize', self.position);
305
+ });
306
+ }
278
307
 
308
+ return this;
309
+ }
310
+ };
311
+ /**
312
+ * Builds an instance of the dynamic component
313
+ * @param {Object} specs - extra functions to extend the component
314
+ * @param {Object} defaults
315
+ * @param {jQuery|HTMLElement|String} [defaults.renderTo] - An optional container in which renders the component
316
+ * @param {Boolean} [defaults.replace] - When the component is appended to its container, clears the place before
317
+ * @param {String} [defaults.title] - title to be displayed in the title bar
318
+ * @param {Boolean} [defaults.resizable] - allow the component to be resizable
319
+ * @param {Boolean} [defaults.draggable] - allow the component to be draggable
320
+ * @param {Number} [defaults.width] - the initial width of the component content
321
+ * @param {Number} [defaults.height] - the intial height of the component content
322
+ * @param {Number} [defaults.minWidth] - the min width for resize
323
+ * @param {Number} [defaults.minHeight] - the min height for resize
324
+ * @param {Number} [defaults.maxWidth] - the max width for resize
325
+ * @param {Number} [defaults.maxHeight] - the max height for resize
326
+ * @param {Number} [defaults.largeWidthThreshold] - the width below which the container will get the class "small"
327
+ * @param {Number} [defaults.smallWidthThreshold] - the width above which the container will get the class "large"
328
+ * @param {Boolean} [defaults.preserveAspectRatio] - preserve ratio on resize
329
+ * @param {jQuery|HTMLElement|String} [defaults.draggableContainer] - the DOMElement the draggable/resizable component will be constraint in
330
+ * @param {Number} [defaults.top] - the initial position top absolute to the relative positioned container
331
+ * @param {Number} [defaults.left] - the initial position left absolute to the relative positioned container
332
+ * @param {Number} [defaults.stackingScope] - in which scope to stack the component
333
+ * @param {Boolean} [defaults.proportionalResize] - resize proportionally in both dimensions
334
+ * @returns {component}
335
+ */
336
+
337
+ var dynComponentFactory = function dynComponentFactory(specs, defaults) {
338
+ var component;
339
+ defaults = _.defaults(defaults || {}, _defaults);
340
+ specs = _.defaults(specs || {}, dynamicComponent);
341
+ component = componentFactory(specs, defaults).setTemplate(layoutTpl).on('init', function () {
342
+ this.id = uuid();
343
+ }).on('render', function () {
344
+ var _this = this;
345
+
346
+ var self = this;
347
+ var $element = this.getElement();
348
+ var config = this.config;
349
+ var $content = $$1('.dynamic-component-content', $element);
350
+ var $titleBar = $$1('.dynamic-component-title-bar', $element);
351
+ var $contentOverlay = $$1('.dynamic-component-layer', $element);
352
+ var $resizeControll = $$1('.dynamic-component-resize-wrapper', $element);
353
+ var pixelRatio = window.devicePixelRatio;
354
+ var interactElement; //prevent parent machine OS to handle its touch gestures on this particular element
355
+
356
+ $element.css('touch-action', 'none'); //keeps moving/resizing positions data
357
+
358
+ self.position = {
359
+ x: this.config.left,
360
+ y: this.config.top,
361
+ width: this.config.width,
362
+ height: this.config.height
363
+ }; //set size + position
364
+
365
+ this.resetPosition();
366
+ this.resetSize(); //init controls
367
+
368
+ $titleBar.on('click touchstart', '.closer', function (e) {
369
+ e.preventDefault();
370
+ self.hide();
371
+ }).on('click touchstart', '.reset', function (e) {
372
+ e.preventDefault();
373
+ self.resetSize();
374
+ });
279
375
  /**
280
- * Reset the component size to it's original value
281
- * @returns {dynamicComponent} chains
282
- * @fires dynamicComponent#resize
376
+ * Init the component content
377
+ * @event dynamicComponent#rendercontent
378
+ * @param {jQueryElement} $content - the rendered content
283
379
  */
284
- resetSize: function resetSize() {
285
- var self = this;
286
- var $element;
287
- var $content;
288
- var $titleBar;
289
-
290
- if (this.is('rendered') && !this.is('disabled')) {
291
- $element = this.getElement();
292
- $content = $$1('.dynamic-component-content', $element);
293
- $titleBar = $$1('.dynamic-component-title-bar', $element);
294
- $element.css({
295
- width: this.config.width + 'px',
296
- height: this.config.height + 'px'
297
- }); //defer to ensure the next reflow occurs before calculating the content size
298
380
 
299
- _.defer(function () {
300
- self.position.width = self.config.width;
301
- self.position.height = self.config.height;
302
- self.position.contentWidth = $titleBar.width();
303
- self.position.contentHeight = $element.height() - $titleBar.outerHeight();
304
- $content.css({
305
- width: self.position.contentWidth + 'px',
306
- height: self.position.contentHeight + 'px'
307
- });
308
- /**
309
- * @event dynamicComponent#resize
310
- * @param {Object} position - the new positions
311
- */
312
-
313
- self.trigger('resize', self.position);
314
- });
315
- }
316
-
317
- return this;
318
- }
319
- };
320
- /**
321
- * Builds an instance of the dynamic component
322
- * @param {Object} specs - extra functions to extend the component
323
- * @param {Object} defaults
324
- * @param {jQuery|HTMLElement|String} [defaults.renderTo] - An optional container in which renders the component
325
- * @param {Boolean} [defaults.replace] - When the component is appended to its container, clears the place before
326
- * @param {String} [defaults.title] - title to be displayed in the title bar
327
- * @param {Boolean} [defaults.resizable] - allow the component to be resizable
328
- * @param {Boolean} [defaults.draggable] - allow the component to be draggable
329
- * @param {Number} [defaults.width] - the initial width of the component content
330
- * @param {Number} [defaults.height] - the intial height of the component content
331
- * @param {Number} [defaults.minWidth] - the min width for resize
332
- * @param {Number} [defaults.minHeight] - the min height for resize
333
- * @param {Number} [defaults.maxWidth] - the max width for resize
334
- * @param {Number} [defaults.maxHeight] - the max height for resize
335
- * @param {Number} [defaults.largeWidthThreshold] - the width below which the container will get the class "small"
336
- * @param {Number} [defaults.smallWidthThreshold] - the width above which the container will get the class "large"
337
- * @param {Boolean} [defaults.preserveAspectRatio] - preserve ratio on resize
338
- * @param {jQuery|HTMLElement|String} [defaults.draggableContainer] - the DOMElement the draggable/resizable component will be constraint in
339
- * @param {Number} [defaults.top] - the initial position top absolute to the relative positioned container
340
- * @param {Number} [defaults.left] - the initial position left absolute to the relative positioned container
341
- * @param {Number} [defaults.stackingScope] - in which scope to stack the component
342
- * @param {Boolean} [defaults.proportionalResize] - resize proportionally in both dimensions
343
- * @returns {component}
344
- */
345
-
346
- var dynComponentFactory = function dynComponentFactory(specs, defaults) {
347
- var component;
348
- defaults = _.defaults(defaults || {}, _defaults);
349
- specs = _.defaults(specs || {}, dynamicComponent);
350
- component = componentFactory(specs, defaults).setTemplate(layoutTpl).on('init', function () {
351
- this.id = uuid();
352
- }).on('render', function () {
353
- var self = this;
354
- var $element = this.getElement();
355
- var config = this.config;
356
- var $content = $$1('.dynamic-component-content', $element);
357
- var $titleBar = $$1('.dynamic-component-title-bar', $element);
358
- var $contentOverlay = $$1('.dynamic-component-layer', $element);
359
- var $resizeControll = $$1('.dynamic-component-resize-wrapper', $element);
360
- var pixelRatio = window.devicePixelRatio;
361
- var interactElement; //prevent parent machine OS to handle its touch gestures on this particular element
362
-
363
- $element.css('touch-action', 'none'); //keeps moving/resizing positions data
364
-
365
- self.position = {
366
- x: this.config.left,
367
- y: this.config.top,
368
- width: this.config.width,
369
- height: this.config.height
370
- }; //set size + position
371
-
372
- this.resetPosition();
373
- this.resetSize(); //init controls
374
-
375
- $titleBar.on('click touchstart', '.closer', function (e) {
376
- e.preventDefault();
377
- self.hide();
378
- }).on('click touchstart', '.reset', function (e) {
379
- e.preventDefault();
380
- self.resetSize();
381
+ this.trigger('rendercontent', $content); //make the dynamic-component draggable + resizable
382
+
383
+ interactElement = interact($element[0]);
384
+
385
+ if (config.draggable) {
386
+ interactElement.draggable({
387
+ inertia: false,
388
+ autoScroll: true,
389
+ manualStart: true,
390
+ restrict: _.merge(getRestriction(), {
391
+ elementRect: {
392
+ left: 0,
393
+ right: 1,
394
+ top: 0,
395
+ bottom: 1
396
+ }
397
+ }),
398
+ onmove: function onmove(event) {
399
+ return moveComponent(event.dx, event.dy);
400
+ },
401
+ onend: function onend() {
402
+ return _this.setCoords();
403
+ }
404
+ }); //manually start interactjs draggable on the handle
405
+
406
+ interact($titleBar[0]).on('down', function (event) {
407
+ var interaction = event.interaction,
408
+ handle = event.currentTarget;
409
+ interaction.start({
410
+ name: 'drag'
411
+ }, interactElement, $element[0]);
381
412
  });
382
- /**
383
- * Init the component content
384
- * @event dynamicComponent#rendercontent
385
- * @param {jQueryElement} $content - the rendered content
386
- */
387
-
388
- this.trigger('rendercontent', $content); //make the dynamic-component draggable + resizable
389
-
390
- interactElement = interact($element[0]);
391
-
392
- if (config.draggable) {
393
- interactElement.draggable({
394
- inertia: false,
395
- autoScroll: true,
396
- manualStart: true,
397
- restrict: _.merge(getRestriction(), {
398
- elementRect: {
399
- left: 0,
400
- right: 1,
401
- top: 0,
402
- bottom: 1
403
- }
404
- }),
405
- onmove: event => moveComponent(event.dx, event.dy),
406
- onend: () => this.setCoords()
407
- }); //manually start interactjs draggable on the handle
408
-
409
- interact($titleBar[0]).on('down', function (event) {
410
- var interaction = event.interaction,
411
- handle = event.currentTarget;
412
- interaction.start({
413
- name: 'drag'
414
- }, interactElement, $element[0]);
415
- });
416
- $$1(window).on('resize.dynamic-component-' + self.id, function () {
417
- var container; //on browser zoom, reset the position to prevent having
418
- //the component pushed outside it's container
413
+ $$1(window).on('resize.dynamic-component-' + self.id, function () {
414
+ var container; //on browser zoom, reset the position to prevent having
415
+ //the component pushed outside it's container
419
416
 
420
- if (window.devicePixelRatio !== pixelRatio) {
421
- pixelRatio = window.devicePixelRatio;
422
- container = getDraggableContainer();
417
+ if (window.devicePixelRatio !== pixelRatio) {
418
+ pixelRatio = window.devicePixelRatio;
419
+ container = getDraggableContainer();
423
420
 
424
- if (position.isInside(container, $element[0]) === false) {
425
- self.resetPosition();
426
- }
421
+ if (position.isInside(container, $element[0]) === false) {
422
+ self.resetPosition();
427
423
  }
428
- });
429
- }
424
+ }
425
+ });
426
+ }
430
427
 
431
- if (config.resizable) {
432
- interactElement.resizable({
433
- preserveAspectRatio: config.preserveAspectRatio,
434
- autoScroll: true,
435
- restrict: getRestriction(),
436
- edges: {
437
- left: false,
438
- right: '.dynamic-component-resize-wrapper',
439
- bottom: '.dynamic-component-resize-wrapper',
440
- top: false
441
- },
442
- onmove: e => resizeComponent(e.rect.width, e.rect.height, e.deltaRect.left, e.deltaRect.top)
443
- });
444
- }
428
+ if (config.resizable) {
429
+ interactElement.resizable({
430
+ preserveAspectRatio: config.preserveAspectRatio,
431
+ autoScroll: true,
432
+ restrict: getRestriction(),
433
+ edges: {
434
+ left: false,
435
+ right: '.dynamic-component-resize-wrapper',
436
+ bottom: '.dynamic-component-resize-wrapper',
437
+ top: false
438
+ },
439
+ onmove: function onmove(e) {
440
+ return resizeComponent(e.rect.width, e.rect.height, e.deltaRect.left, e.deltaRect.top);
441
+ }
442
+ });
443
+ }
445
444
 
446
- interactElement.on('dragstart resizeinertiastart', function () {
447
- $contentOverlay.addClass('dragging-active');
448
- $content.addClass('moving');
449
- $titleBar.addClass('moving');
450
- }).on('dragend', function () {
451
- $contentOverlay.removeClass('dragging-active');
452
- $content.removeClass('moving');
453
- $titleBar.removeClass('moving');
454
- }).on('resizestart', function () {
445
+ interactElement.on('dragstart resizeinertiastart', function () {
446
+ $contentOverlay.addClass('dragging-active');
447
+ $content.addClass('moving');
448
+ $titleBar.addClass('moving');
449
+ }).on('dragend', function () {
450
+ $contentOverlay.removeClass('dragging-active');
451
+ $content.removeClass('moving');
452
+ $titleBar.removeClass('moving');
453
+ }).on('resizestart', function () {
454
+ $contentOverlay.addClass('dragging-active');
455
+ $resizeControll.addClass('resizing');
456
+ $content.addClass('sizing');
457
+ }).on('resizeend', function () {
458
+ $contentOverlay.removeClass('dragging-active');
459
+ $resizeControll.removeClass('resizing');
460
+ $content.removeClass('sizing');
461
+ }); //interact sometimes doesn't trigger the start event if the move is quick and ends over an iframe...
462
+
463
+ $element.on('mousedown', function () {
464
+ if (/\-resize/.test($$1('html').css('cursor')) && !$contentOverlay.hasClass('dragging-active')) {
455
465
  $contentOverlay.addClass('dragging-active');
456
- $resizeControll.addClass('resizing');
457
- $content.addClass('sizing');
458
- }).on('resizeend', function () {
459
- $contentOverlay.removeClass('dragging-active');
460
- $resizeControll.removeClass('resizing');
461
- $content.removeClass('sizing');
462
- }); //interact sometimes doesn't trigger the start event if the move is quick and ends over an iframe...
463
-
464
- $element.on('mousedown', function () {
465
- if (/\-resize/.test($$1('html').css('cursor')) && !$contentOverlay.hasClass('dragging-active')) {
466
- $contentOverlay.addClass('dragging-active');
467
- }
468
- }); // use after event because the component is hidden during regular event
469
-
470
- this.after('show', () => {
471
- const viewport = getParent()[0].getBoundingClientRect();
472
- let {
473
- width,
474
- height
475
- } = this.position;
476
- let x = 0;
477
- let y = 0;
478
- let resize = false;
479
-
480
- if (width > viewport.width) {
481
- // if proportional resize enabled calculate scale rate based on width
482
- // and apply it to height
483
- height = config.proportionalResize ? config.minHeight * (viewport.width / config.minWidth) : viewport.width * (this.position.height / this.position.width);
484
- width = viewport.width;
485
- resize = true;
486
-
487
- if (this.position.x) {
488
- x = -this.position.x;
489
- }
490
- } else if (this.position.x + width > viewport.width) {
491
- x = -this.position.x;
466
+ }
467
+ }); // use after event because the component is hidden during regular event
468
+
469
+ this.after('show', function () {
470
+ var viewport = getParent()[0].getBoundingClientRect();
471
+ var _this$position = _this.position,
472
+ width = _this$position.width,
473
+ height = _this$position.height;
474
+ var x = 0;
475
+ var y = 0;
476
+ var resize = false;
477
+
478
+ if (width > viewport.width) {
479
+ // if proportional resize enabled calculate scale rate based on width
480
+ // and apply it to height
481
+ height = config.proportionalResize ? config.minHeight * (viewport.width / config.minWidth) : viewport.width * (_this.position.height / _this.position.width);
482
+ width = viewport.width;
483
+ resize = true;
484
+
485
+ if (_this.position.x) {
486
+ x = -_this.position.x;
492
487
  }
488
+ } else if (_this.position.x + width > viewport.width) {
489
+ x = -_this.position.x;
490
+ }
493
491
 
494
- if (height > viewport.height) {
495
- height = viewport.height; // if proportional resize enabled calculate scale rate based on height
496
- // and apply it to width
497
-
498
- width = config.proportionalResize ? config.minWidth * (viewport.height / config.minHeight) : viewport.height * (this.position.width / this.position.height);
499
- resize = true;
492
+ if (height > viewport.height) {
493
+ height = viewport.height; // if proportional resize enabled calculate scale rate based on height
494
+ // and apply it to width
500
495
 
501
- if (this.position.y) {
502
- y = -this.position.y;
503
- }
504
- } else if (this.position.y + height > viewport.height) {
505
- y = -this.position.y;
506
- }
496
+ width = config.proportionalResize ? config.minWidth * (viewport.height / config.minHeight) : viewport.height * (_this.position.width / _this.position.height);
497
+ resize = true;
507
498
 
508
- if (resize) {
509
- resizeComponent(width, height, x, y, true);
510
- } else if (x || y) {
511
- moveComponent(x, y);
499
+ if (_this.position.y) {
500
+ y = -_this.position.y;
512
501
  }
513
- });
502
+ } else if (_this.position.y + height > viewport.height) {
503
+ y = -_this.position.y;
504
+ }
514
505
 
515
- function getRestriction() {
516
- var draggableContainer = getDraggableContainer();
506
+ if (resize) {
507
+ resizeComponent(width, height, x, y, true);
508
+ } else if (x || y) {
509
+ moveComponent(x, y);
510
+ }
511
+ });
517
512
 
518
- if (!draggableContainer) {
519
- return {
520
- restriction: 'parent',
521
- endOnly: false
522
- };
523
- }
513
+ function getRestriction() {
514
+ var draggableContainer = getDraggableContainer();
524
515
 
516
+ if (!draggableContainer) {
525
517
  return {
526
- restriction: draggableContainer,
518
+ restriction: 'parent',
527
519
  endOnly: false
528
520
  };
529
521
  }
530
522
 
531
- function getDraggableContainer() {
532
- var draggableContainer = config.draggableContainer;
523
+ return {
524
+ restriction: draggableContainer,
525
+ endOnly: false
526
+ };
527
+ }
533
528
 
534
- if (draggableContainer instanceof $$1 && draggableContainer.length) {
535
- draggableContainer = draggableContainer[0];
536
- }
529
+ function getDraggableContainer() {
530
+ var draggableContainer = config.draggableContainer;
537
531
 
538
- return draggableContainer;
532
+ if (draggableContainer instanceof $$1 && draggableContainer.length) {
533
+ draggableContainer = draggableContainer[0];
539
534
  }
540
535
 
541
- function getParent() {
542
- const draggableContainer = getDraggableContainer();
536
+ return draggableContainer;
537
+ }
543
538
 
544
- if (!draggableContainer || draggableContainer === 'parent') {
545
- return $element.parent();
546
- }
539
+ function getParent() {
540
+ var draggableContainer = getDraggableContainer();
547
541
 
548
- return $$1(draggableContainer);
542
+ if (!draggableContainer || draggableContainer === 'parent') {
543
+ return $element.parent();
549
544
  }
550
- /**
551
- * Callback for on move event
552
- * @param {Number} x
553
- * @param {Number} y
554
- */
555
545
 
546
+ return $$1(draggableContainer);
547
+ }
548
+ /**
549
+ * Callback for on move event
550
+ * @param {Number} x
551
+ * @param {Number} y
552
+ */
556
553
 
557
- function moveComponent(x, y) {
558
- interactUtils.moveElement($element, x, y);
559
- self.setCoords();
560
- self.trigger('move', self.position);
561
- }
562
- /**
563
- * Callback for on resize event
564
- * @param {Number} width
565
- * @param {Number} height
566
- * @param {Number} x
567
- * @param {Number} y
568
- * @param {Boolean} updateElementOffset - force element to be moved to provided coords
569
- */
554
+
555
+ function moveComponent(x, y) {
556
+ interactUtils.moveElement($element, x, y);
557
+ self.setCoords();
558
+ self.trigger('move', self.position);
559
+ }
560
+ /**
561
+ * Callback for on resize event
562
+ * @param {Number} width
563
+ * @param {Number} height
564
+ * @param {Number} x
565
+ * @param {Number} y
566
+ * @param {Boolean} updateElementOffset - force element to be moved to provided coords
567
+ */
570
568
 
571
569
 
572
- function resizeComponent(width, height) {
573
- let x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
574
- let y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
575
- let updateElementOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
576
- const $parent = getParent();
577
- let {
578
- left: elementOffsetLeft,
579
- top: elementOffsetTop
580
- } = $element.offset();
581
- const parentOffset = $parent.offset();
582
-
583
- if (updateElementOffset) {
584
- elementOffsetLeft += x;
585
- elementOffsetTop += y;
586
- } // if proportional resize enabled calculate scale rate
587
- // and apply it to width and height
588
-
589
-
590
- const dimensions = calculateSize(width, height);
591
- width = calculateOverlap(dimensions.width, elementOffsetLeft, parentOffset.left, $parent.width());
592
- height = calculateOverlap(dimensions.height, elementOffsetTop, parentOffset.top, $parent.height());
593
-
594
- if (height !== null && width !== null) {
595
- if (width <= config.smallWidthThreshold) {
596
- $element.addClass('small').removeClass('large');
597
- } else if (width >= config.largeWidthThreshold) {
598
- $element.addClass('large').removeClass('small');
599
- } else {
600
- $element.removeClass('small').removeClass('large');
601
- }
570
+ function resizeComponent(width, height) {
571
+ var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
572
+ var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
573
+ var updateElementOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
574
+ var $parent = getParent();
602
575
 
603
- interactUtils.moveElement($element, width > config.minWidth && width < config.maxWidth || updateElementOffset ? x : 0, height > config.minHeight && height < config.maxHeight || updateElementOffset ? y : 0);
604
- self.position.width = width;
605
- self.position.height = height;
606
- self.setCoords();
607
- $element.css({
608
- width: width + 'px',
609
- height: height + 'px'
610
- });
576
+ var _$element$offset = $element.offset(),
577
+ elementOffsetLeft = _$element$offset.left,
578
+ elementOffsetTop = _$element$offset.top;
611
579
 
612
- _.defer(function () {
613
- self.position.contentWidth = $titleBar.width();
614
- self.position.contentHeight = $element.height() - $titleBar.outerHeight();
615
- $content.css({
616
- width: self.position.contentWidth + 'px',
617
- height: self.position.contentHeight + 'px'
618
- });
619
- self.trigger('resize', self.position);
620
- });
621
- }
622
- }
623
- /**
624
- * check if given side of dynamic component is overlapping the container and calculate size of that side
625
- * @param {Number} side - side value of the component to check and calculate, cold be height or width
626
- * @param {Number} elOffset - offset value towards child to parent container
627
- * @param {Number} parentOffset - offset value towards parent container to its ancestor
628
- * @returns {Number|null} - new width or height values for the side of the component or null if there is no overlap between it and container
629
- */
580
+ var parentOffset = $parent.offset();
630
581
 
582
+ if (updateElementOffset) {
583
+ elementOffsetLeft += x;
584
+ elementOffsetTop += y;
585
+ } // if proportional resize enabled calculate scale rate
586
+ // and apply it to width and height
631
587
 
632
- function calculateOverlap(side, elOffset, parentOffset, parentValue) {
633
- var result = side;
634
- var fullSizeSide = elOffset + side;
635
- var fullSizeParent = parentOffset + parentValue;
636
588
 
637
- if (fullSizeSide > fullSizeParent) {
638
- if (config.proportionalResize) {
639
- result = null;
640
- } else {
641
- result -= fullSizeSide - fullSizeParent;
642
- }
589
+ var dimensions = calculateSize(width, height);
590
+ width = calculateOverlap(dimensions.width, elementOffsetLeft, parentOffset.left, $parent.width());
591
+ height = calculateOverlap(dimensions.height, elementOffsetTop, parentOffset.top, $parent.height());
592
+
593
+ if (height !== null && width !== null) {
594
+ if (width <= config.smallWidthThreshold) {
595
+ $element.addClass('small').removeClass('large');
596
+ } else if (width >= config.largeWidthThreshold) {
597
+ $element.addClass('large').removeClass('small');
598
+ } else {
599
+ $element.removeClass('small').removeClass('large');
643
600
  }
644
601
 
645
- return result;
602
+ interactUtils.moveElement($element, width > config.minWidth && width < config.maxWidth || updateElementOffset ? x : 0, height > config.minHeight && height < config.maxHeight || updateElementOffset ? y : 0);
603
+ self.position.width = width;
604
+ self.position.height = height;
605
+ self.setCoords();
606
+ $element.css({
607
+ width: width + 'px',
608
+ height: height + 'px'
609
+ });
610
+
611
+ _.defer(function () {
612
+ self.position.contentWidth = $titleBar.width();
613
+ self.position.contentHeight = $element.height() - $titleBar.outerHeight();
614
+ $content.css({
615
+ width: self.position.contentWidth + 'px',
616
+ height: self.position.contentHeight + 'px'
617
+ });
618
+ self.trigger('resize', self.position);
619
+ });
646
620
  }
647
- /**
648
- * calculates size of the dynamic component compared to configured max/min values and scale rate coefficient applied
649
- * @param {Number} width - width of the component at the moment of resizing
650
- * @param {Number} height - height of the component at the moment of resizing
651
- * @returns {width,height} - object with adjusted weight and height
652
- */
621
+ }
622
+ /**
623
+ * check if given side of dynamic component is overlapping the container and calculate size of that side
624
+ * @param {Number} side - side value of the component to check and calculate, cold be height or width
625
+ * @param {Number} elOffset - offset value towards child to parent container
626
+ * @param {Number} parentOffset - offset value towards parent container to its ancestor
627
+ * @returns {Number|null} - new width or height values for the side of the component or null if there is no overlap between it and container
628
+ */
653
629
 
654
630
 
655
- function calculateSize(width, height) {
656
- var scaleRate;
631
+ function calculateOverlap(side, elOffset, parentOffset, parentValue) {
632
+ var result = side;
633
+ var fullSizeSide = elOffset + side;
634
+ var fullSizeParent = parentOffset + parentValue;
657
635
 
636
+ if (fullSizeSide > fullSizeParent) {
658
637
  if (config.proportionalResize) {
659
- scaleRate = Math.max(width / config.minWidth, height / config.minHeight);
660
- width = config.minWidth * scaleRate;
661
- height = config.minHeight * scaleRate;
638
+ result = null;
639
+ } else {
640
+ result -= fullSizeSide - fullSizeParent;
662
641
  }
642
+ }
663
643
 
664
- if (width < config.minWidth) {
665
- width = config.minWidth;
666
- } else if (width > config.maxWidth) {
667
- width = config.maxWidth;
668
- }
644
+ return result;
645
+ }
646
+ /**
647
+ * calculates size of the dynamic component compared to configured max/min values and scale rate coefficient applied
648
+ * @param {Number} width - width of the component at the moment of resizing
649
+ * @param {Number} height - height of the component at the moment of resizing
650
+ * @returns {width,height} - object with adjusted weight and height
651
+ */
669
652
 
670
- if (height < config.minHeight) {
671
- height = config.minHeight;
672
- } else if (height > config.maxHeight) {
673
- height = config.maxHeight;
674
- }
675
653
 
676
- return {
677
- width: width,
678
- height: height
679
- };
654
+ function calculateSize(width, height) {
655
+ var scaleRate;
656
+
657
+ if (config.proportionalResize) {
658
+ scaleRate = Math.max(width / config.minWidth, height / config.minHeight);
659
+ width = config.minWidth * scaleRate;
660
+ height = config.minHeight * scaleRate;
680
661
  }
681
- }).on('destroy', function () {
682
- $$1(window).off('resize.dynamic-component-' + this.id);
683
- });
684
- return makeStackable(component, {
685
- stackingScope: defaults.stackingScope
686
- });
687
- };
688
662
 
689
- return dynComponentFactory;
663
+ if (width < config.minWidth) {
664
+ width = config.minWidth;
665
+ } else if (width > config.maxWidth) {
666
+ width = config.maxWidth;
667
+ }
668
+
669
+ if (height < config.minHeight) {
670
+ height = config.minHeight;
671
+ } else if (height > config.maxHeight) {
672
+ height = config.maxHeight;
673
+ }
674
+
675
+ return {
676
+ width: width,
677
+ height: height
678
+ };
679
+ }
680
+ }).on('destroy', function () {
681
+ $$1(window).off('resize.dynamic-component-' + this.id);
682
+ });
683
+ return makeStackable(component, {
684
+ stackingScope: defaults.stackingScope
685
+ });
686
+ };
687
+
688
+ return dynComponentFactory;
690
689
 
691
690
  });