@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,708 +1,699 @@
1
1
  define(['jquery', 'lodash', 'ui/component', 'handlebars', 'i18n', 'lib/dompurify/purify', 'ui/mediaEditor/plugins/mediaDimension/helper', 'nouislider', 'ui/tooltip', 'css!ui/mediaEditor/plugins/mediaDimension/style.css'], function ($$1, _, component, Handlebars, __, DOMPurify, helper, nouislider, tooltip, style_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
- component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
6
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
8
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
9
- helper = helper && Object.prototype.hasOwnProperty.call(helper, 'default') ? helper['default'] : helper;
10
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
6
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
8
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
9
+ helper = helper && Object.prototype.hasOwnProperty.call(helper, 'default') ? helper['default'] : helper;
10
+
11
+ function _typeof(obj) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
15
+ return typeof obj;
16
+ } : function (obj) {
17
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18
+ }, _typeof(obj);
19
+ }
20
+
21
+ function Helpers0 (hb) {
22
+ //register a i18n helper
23
+ hb.registerHelper('__', function (key) {
24
+ return __(key);
25
+ });
11
26
  /**
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * as published by the Free Software Foundation; under version 2
15
- * of the License (non-upgradable).
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
- *
26
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
27
+ * Register dompurify helper
27
28
  *
29
+ * https://github.com/cure53/DOMPurify
30
+ * with config SAFE_FOR_TEMPLATES: true
31
+ * to make output safe for template systems
32
+ */
33
+
34
+ hb.registerHelper('dompurify', function (context) {
35
+ return DOMPurify.sanitize(context);
36
+ });
37
+ /**
38
+ * Register join helper
28
39
  *
40
+ * Example :
41
+ * var values = {a:v1, b:v2, c:v3};
42
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
43
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
29
44
  */
30
- function Helpers0 (hb) {
31
- //register a i18n helper
32
- hb.registerHelper('__', function (key) {
33
- return __(key);
34
- });
35
- /**
36
- * Register dompurify helper
37
- *
38
- * https://github.com/cure53/DOMPurify
39
- * with config SAFE_FOR_TEMPLATES: true
40
- * to make output safe for template systems
41
- */
42
45
 
43
- hb.registerHelper('dompurify', function (context) {
44
- return DOMPurify.sanitize(context);
45
- });
46
- /**
47
- * Register join helper
48
- *
49
- * Example :
50
- * var values = {a:v1, b:v2, c:v3};
51
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
52
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
53
- */
46
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
47
+ var fragments = [];
48
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
49
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
50
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
54
51
 
55
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
56
- var fragments = [];
57
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
58
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
59
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
60
-
61
- _.forIn(arr, function (value, key) {
62
- var fragment = '';
63
-
64
- if (value !== null || value !== undefined) {
65
- if (typeof value === 'boolean') {
66
- value = value ? 'true' : 'false';
67
- } else if (typeof value === 'object') {
68
- value = _.values(value).join(' ');
69
- }
70
- } else {
71
- value = '';
72
- }
52
+ _.forIn(arr, function (value, key) {
53
+ var fragment = '';
73
54
 
74
- if (keyValueGlue !== undefined) {
75
- fragment += key + keyValueGlue;
55
+ if (value !== null || value !== undefined) {
56
+ if (typeof value === 'boolean') {
57
+ value = value ? 'true' : 'false';
58
+ } else if (_typeof(value) === 'object') {
59
+ value = _.values(value).join(' ');
76
60
  }
61
+ } else {
62
+ value = '';
63
+ }
77
64
 
78
- fragment += wrapper + value + wrapper;
79
- fragments.push(fragment);
80
- });
81
-
82
- return fragments.join(fragmentGlue);
83
- }); //register a classic "for loop" helper
84
- //it also adds a local variable "i" as the index in each iteration loop
85
-
86
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
87
- var ret = '';
88
- startIndex = parseInt(startIndex);
89
- stopIndex = parseInt(stopIndex);
90
- increment = parseInt(increment);
91
-
92
- for (var i = startIndex; i < stopIndex; i += increment) {
93
- ret += options.fn(_.extend({}, this, {
94
- i: i
95
- }));
65
+ if (keyValueGlue !== undefined) {
66
+ fragment += key + keyValueGlue;
96
67
  }
97
68
 
98
- return ret;
69
+ fragment += wrapper + value + wrapper;
70
+ fragments.push(fragment);
99
71
  });
100
- hb.registerHelper('equal', function (var1, var2, options) {
101
- if (var1 == var2) {
102
- return options.fn(this);
103
- } else {
104
- return options.inverse(this);
105
- }
106
- }); // register a "get property" helper
107
- // it gets the named property from the provided context
108
72
 
109
- hb.registerHelper('property', function (name, context) {
110
- return context[name] || '';
111
- }); // register an 'includes' helper
112
- // it checks if value is in array
73
+ return fragments.join(fragmentGlue);
74
+ }); //register a classic "for loop" helper
75
+ //it also adds a local variable "i" as the index in each iteration loop
113
76
 
114
- hb.registerHelper('includes', function (haystack, needle, options) {
115
- if (_.contains(haystack, needle)) {
116
- return options.fn(this);
117
- }
118
- });
119
- }
77
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
78
+ var ret = '';
79
+ startIndex = parseInt(startIndex);
80
+ stopIndex = parseInt(stopIndex);
81
+ increment = parseInt(increment);
120
82
 
121
- if (!Helpers0.__initialized) {
122
- Helpers0(Handlebars);
123
- Helpers0.__initialized = true;
124
- }
125
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
126
- this.compilerInfo = [4,'>= 1.0.0'];
127
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
128
- var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
129
-
130
- function program1(depth0,data) {
131
-
132
-
133
- return "checked=\"checked\"";
83
+ for (var i = startIndex; i < stopIndex; i += increment) {
84
+ ret += options.fn(_.extend({}, this, {
85
+ i: i
86
+ }));
134
87
  }
135
88
 
136
- buffer += "<div class=\"media-sizer media-sizer-synced\">\n\n <div class=\"media-sizer-responsive-toggle\">\n <label>\n <input type=\"checkbox\" ";
137
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.responsive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
138
- if(stack1 || stack1 === 0) { buffer += stack1; }
139
- buffer += " class=\"media-mode-switch\"/>\n <span class=\"icon-checkbox\"></span>\n "
140
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Responsive mode", options) : helperMissing.call(depth0, "__", "Responsive mode", options)))
141
- + "\n </label>\n <span class=\"icon-help tooltipstered\" data-tooltip=\"~ .tooltip-content:first\" data-tooltip-theme=\"warning\"></span>\n\n <div class=\"tooltip-content\">\n "
142
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Media resize along with their container, e.g. 50% means half of the container size not half of the media size.", options) : helperMissing.call(depth0, "__", "Media resize along with their container, e.g. 50% means half of the container size not half of the media size.", options)))
143
- + "\n </div>\n </div>\n\n\n <div class=\"media-sizer-percent\">\n <label for=\"media-sizer-percent-width\">"
144
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Size", options) : helperMissing.call(depth0, "__", "Size", options)))
145
- + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-percent-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">%</span>\n </span>\n\n <div class=\"media-sizer-reset media-sizer-reset-percent\" data-unit=\"percent\">\n <span class=\"icon-reset\"></span>\n </div>\n\n <div class=\"media-sizer-slider-box\">\n <div class=\"media-sizer-slider\"></div>\n </div>\n </div>\n\n <div class=\"media-sizer-pixel\">\n <div class=\"media-sizer-sync\">\n <span class=\"icon-link\"></span>\n </div>\n <div>\n <label for=\"media-sizer-pixel-width\">"
146
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Width", options) : helperMissing.call(depth0, "__", "Width", options)))
147
- + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-pixel-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">px</span>\n </span>\n </div>\n <div>\n <label for=\"media-sizer-pixel-height\">"
148
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Height", options) : helperMissing.call(depth0, "__", "Height", options)))
149
- + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"height\" id=\"media-sizer-pixel-height\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">px</span>\n </span>\n </div>\n <div class=\"media-sizer-reset media-sizer-reset-pixel\" data-unit=\"pixel\">\n <span class=\"icon-reset\"></span>\n </div>\n </div>\n</div>\n";
150
- return buffer;
151
- });
152
- function tpl(data, options, asString) {
153
- var html = Template(data, options);
154
- return (asString || true) ? html : $(html);
89
+ return ret;
90
+ });
91
+ hb.registerHelper('equal', function (var1, var2, options) {
92
+ if (var1 == var2) {
93
+ return options.fn(this);
94
+ } else {
95
+ return options.inverse(this);
96
+ }
97
+ }); // register a "get property" helper
98
+ // it gets the named property from the provided context
99
+
100
+ hb.registerHelper('property', function (name, context) {
101
+ return context[name] || '';
102
+ }); // register an 'includes' helper
103
+ // it checks if value is in array
104
+
105
+ hb.registerHelper('includes', function (haystack, needle, options) {
106
+ if (_.contains(haystack, needle)) {
107
+ return options.fn(this);
108
+ }
109
+ });
110
+ }
111
+
112
+ if (!Helpers0.__initialized) {
113
+ Helpers0(Handlebars);
114
+ Helpers0.__initialized = true;
115
+ }
116
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
117
+ this.compilerInfo = [4,'>= 1.0.0'];
118
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
119
+ var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
120
+
121
+ function program1(depth0,data) {
122
+
123
+
124
+ return "checked=\"checked\"";
155
125
  }
156
126
 
127
+ buffer += "<div class=\"media-sizer media-sizer-synced\">\n\n <div class=\"media-sizer-responsive-toggle\">\n <label>\n <input type=\"checkbox\" ";
128
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.responsive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
129
+ if(stack1 || stack1 === 0) { buffer += stack1; }
130
+ buffer += " class=\"media-mode-switch\"/>\n <span class=\"icon-checkbox\"></span>\n "
131
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Responsive mode", options) : helperMissing.call(depth0, "__", "Responsive mode", options)))
132
+ + "\n </label>\n <span class=\"icon-help tooltipstered\" data-tooltip=\"~ .tooltip-content:first\" data-tooltip-theme=\"warning\"></span>\n\n <div class=\"tooltip-content\">\n "
133
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Media resize along with their container, e.g. 50% means half of the container size not half of the media size.", options) : helperMissing.call(depth0, "__", "Media resize along with their container, e.g. 50% means half of the container size not half of the media size.", options)))
134
+ + "\n </div>\n </div>\n\n\n <div class=\"media-sizer-percent\">\n <label for=\"media-sizer-percent-width\">"
135
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Size", options) : helperMissing.call(depth0, "__", "Size", options)))
136
+ + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-percent-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">%</span>\n </span>\n\n <div class=\"media-sizer-reset media-sizer-reset-percent\" data-unit=\"percent\">\n <span class=\"icon-reset\"></span>\n </div>\n\n <div class=\"media-sizer-slider-box\">\n <div class=\"media-sizer-slider\"></div>\n </div>\n </div>\n\n <div class=\"media-sizer-pixel\">\n <div class=\"media-sizer-sync\">\n <span class=\"icon-link\"></span>\n </div>\n <div>\n <label for=\"media-sizer-pixel-width\">"
137
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Width", options) : helperMissing.call(depth0, "__", "Width", options)))
138
+ + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-pixel-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">px</span>\n </span>\n </div>\n <div>\n <label for=\"media-sizer-pixel-height\">"
139
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Height", options) : helperMissing.call(depth0, "__", "Height", options)))
140
+ + "</label>\n <span class=\"item-editor-unit-input-box\" style=\"display:-moz-box;\">\n <input type=\"text\" name=\"height\" id=\"media-sizer-pixel-height\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n <span class=\"unit-indicator\">px</span>\n </span>\n </div>\n <div class=\"media-sizer-reset media-sizer-reset-pixel\" data-unit=\"pixel\">\n <span class=\"icon-reset\"></span>\n </div>\n </div>\n</div>\n";
141
+ return buffer;
142
+ });
143
+ function tpl(data, options, asString) {
144
+ var html = Template(data, options);
145
+ return (asString || true) ? html : $(html);
146
+ }
147
+
148
+ /**
149
+ * This program is free software; you can redistribute it and/or
150
+ * modify it under the terms of the GNU General Public License
151
+ * as published by the Free Software Foundation; under version 2
152
+ * of the License (non-upgradable).
153
+ *
154
+ * This program is distributed in the hope that it will be useful,
155
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
156
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
157
+ * GNU General Public License for more details.
158
+ *
159
+ * You should have received a copy of the GNU General Public License
160
+ * along with this program; if not, write to the Free Software
161
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
162
+ *
163
+ * Copyright (c) 2018 (original work) Open Assessment Technologies SA;
164
+ */
165
+ /**
166
+ * Size properties of the media
167
+ * @typedef {Object} sizeProps
168
+ * @property px {{
169
+ * natural: {
170
+ * width: number,
171
+ * height: number,
172
+ * },
173
+ * current: {
174
+ * width: number,
175
+ * height: number,
176
+ * }
177
+ * }}
178
+ * @property '%' {{
179
+ * natural: {
180
+ * width: number,
181
+ * height: number,
182
+ * },
183
+ * current: {
184
+ * width: number,
185
+ * height: number,
186
+ * }
187
+ * }}
188
+ * @property ratio {{
189
+ * natural: number,
190
+ * current: number
191
+ * }}
192
+ * @property currentUtil string
193
+ */
194
+
195
+ /**
196
+ * Default values
197
+ * precision - precision for all calculations (0.00001)
198
+ *
199
+ * @type {{
200
+ * showResponsiveToggle: boolean,
201
+ * showSync: boolean,
202
+ * showReset: boolean,
203
+ * denyCustomRatio: boolean,
204
+ * width: number,
205
+ * height: number,
206
+ * minWidth: number,
207
+ * maxWidth: number,
208
+ * sizeProps: sizeProps,
209
+ * precision: number
210
+ * }}
211
+ * @private
212
+ */
213
+
214
+ var defaultConfig = {
215
+ showResponsiveToggle: true,
216
+ showSync: true,
217
+ showReset: true,
218
+ sizeProps: {
219
+ px: {
220
+ current: {
221
+ width: 0,
222
+ height: 0
223
+ }
224
+ },
225
+ '%': {
226
+ current: {
227
+ width: 0,
228
+ height: null
229
+ }
230
+ },
231
+ ratio: {
232
+ natural: 1,
233
+ current: 1
234
+ },
235
+ currentUtil: '%',
236
+ slider: {
237
+ min: 1,
238
+ max: 100,
239
+ start: 100
240
+ }
241
+ },
242
+ denyCustomRatio: false,
243
+ syncDimensions: true,
244
+ width: 0,
245
+ height: 0,
246
+ minWidth: 0,
247
+ maxWidth: 0,
248
+ precision: 5
249
+ };
250
+ /**
251
+ * Creates mediaDimension component
252
+ * @param {jQueryElement} $container
253
+ * @param {Object} media
254
+ * @param {Object} config
255
+ * @fires "changed" - on State changed
256
+ * @returns {component|*} mediaDimensionComponent
257
+ */
258
+
259
+ function mediaDimensionFactory($container, media, config) {
157
260
  /**
158
- * This program is free software; you can redistribute it and/or
159
- * modify it under the terms of the GNU General Public License
160
- * as published by the Free Software Foundation; under version 2
161
- * of the License (non-upgradable).
162
- *
163
- * This program is distributed in the hope that it will be useful,
164
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
165
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
166
- * GNU General Public License for more details.
167
- *
168
- * You should have received a copy of the GNU General Public License
169
- * along with this program; if not, write to the Free Software
170
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
171
- *
172
- * Copyright (c) 2018 (original work) Open Assessment Technologies SA;
261
+ * Collections of the jquery elements grouped by type
173
262
  */
263
+ var $blocks, $slider, $fields;
174
264
  /**
175
- * Size properties of the media
176
- * @typedef {Object} sizeProps
177
- * @property px {{
178
- * natural: {
179
- * width: number,
180
- * height: number,
181
- * },
182
- * current: {
183
- * width: number,
184
- * height: number,
185
- * }
186
- * }}
187
- * @property '%' {{
188
- * natural: {
189
- * width: number,
190
- * height: number,
191
- * },
192
- * current: {
193
- * width: number,
194
- * height: number,
195
- * }
196
- * }}
197
- * @property ratio {{
198
- * natural: number,
199
- * current: number
200
- * }}
201
- * @property currentUtil string
265
+ * Template of the dimension controller
202
266
  */
203
267
 
268
+ var $template;
204
269
  /**
205
- * Default values
206
- * precision - precision for all calculations (0.00001)
207
- *
208
- * @type {{
209
- * showResponsiveToggle: boolean,
210
- * showSync: boolean,
211
- * showReset: boolean,
212
- * denyCustomRatio: boolean,
213
- * width: number,
214
- * height: number,
215
- * minWidth: number,
216
- * maxWidth: number,
217
- * sizeProps: sizeProps,
218
- * precision: number
219
- * }}
220
- * @private
270
+ * Size properties of the media control panel
271
+ * @typedef {Object} mediaSizeProps
272
+ * @property showResponsiveToggle boolean
273
+ * @property responsive boolean
274
+ * @property sizeProps sizeProps
275
+ * @property syncDimensions boolean
276
+ * @property denyCustomRatio boolean
277
+ * @property precision number
278
+ * @property showReset boolean
221
279
  */
222
280
 
223
- const defaultConfig = {
224
- showResponsiveToggle: true,
225
- showSync: true,
226
- showReset: true,
227
- sizeProps: {
228
- px: {
229
- current: {
230
- width: 0,
231
- height: 0
232
- }
233
- },
234
- '%': {
235
- current: {
236
- width: 0,
237
- height: null
238
- }
239
- },
240
- ratio: {
241
- natural: 1,
242
- current: 1
243
- },
244
- currentUtil: '%',
245
- slider: {
246
- min: 1,
247
- max: 100,
248
- start: 100
249
- }
250
- },
251
- denyCustomRatio: false,
252
- syncDimensions: true,
253
- width: 0,
254
- height: 0,
255
- minWidth: 0,
256
- maxWidth: 0,
257
- precision: 5
258
- };
259
281
  /**
260
- * Creates mediaDimension component
261
- * @param {jQueryElement} $container
262
- * @param {Object} media
263
- * @param {Object} config
264
- * @fires "changed" - on State changed
265
- * @returns {component|*} mediaDimensionComponent
282
+ * Configuration
283
+ * @type {mediaSizeProps}
284
+ * @private
266
285
  */
267
286
 
268
- function mediaDimensionFactory($container, media, config) {
269
- /**
270
- * Collections of the jquery elements grouped by type
271
- */
272
- let $blocks, $slider, $fields;
273
- /**
274
- * Template of the dimension controller
275
- */
276
-
277
- let $template;
278
- /**
279
- * Size properties of the media control panel
280
- * @typedef {Object} mediaSizeProps
281
- * @property showResponsiveToggle boolean
282
- * @property responsive boolean
283
- * @property sizeProps sizeProps
284
- * @property syncDimensions boolean
285
- * @property denyCustomRatio boolean
286
- * @property precision number
287
- * @property showReset boolean
288
- */
287
+ var initialConfig;
288
+ /**
289
+ * Calculate propSizes to have correct sizes for the shown image
290
+ * @param {Object} conf
291
+ * @returns {Object}
292
+ */
289
293
 
290
- /**
291
- * Configuration
292
- * @type {mediaSizeProps}
293
- * @private
294
- */
294
+ var calculateCurrentSizes = function calculateCurrentSizes(conf) {
295
+ var mediaContainerWidth = helper.getMediaContainerWidth(media);
296
+ return helper.applyDimensions(conf, {
297
+ width: mediaContainerWidth < conf.sizeProps.px.natural.width ? mediaContainerWidth : conf.sizeProps.px.natural.width,
298
+ maxWidth: helper.getMediaContainerWidth(media)
299
+ });
300
+ };
301
+ /**
302
+ * Return oroginal size
303
+ * @returns {Object}
304
+ */
295
305
 
296
- let initialConfig;
297
- /**
298
- * Calculate propSizes to have correct sizes for the shown image
299
- * @param {Object} conf
300
- * @returns {Object}
301
- */
302
306
 
303
- const calculateCurrentSizes = function calculateCurrentSizes(conf) {
304
- const mediaContainerWidth = helper.getMediaContainerWidth(media);
305
- return helper.applyDimensions(conf, {
306
- width: mediaContainerWidth < conf.sizeProps.px.natural.width ? mediaContainerWidth : conf.sizeProps.px.natural.width,
307
- maxWidth: helper.getMediaContainerWidth(media)
308
- });
307
+ function getOriginalSize() {
308
+ // for images naturalWidth, for video videoWidth, for youtube iframe width
309
+ return {
310
+ width: media.$node[0].naturalWidth || media.$node[0].videoWidth || media.$node[0].width,
311
+ height: media.$node[0].naturalHeight || media.$node[0].videoHeight || media.$node[0].height
309
312
  };
310
- /**
311
- * Return oroginal size
312
- * @returns {Object}
313
- */
313
+ }
314
+ /**
315
+ * Current component
316
+ */
314
317
 
315
318
 
316
- function getOriginalSize() {
317
- // for images naturalWidth, for video videoWidth, for youtube iframe width
318
- return {
319
- width: media.$node[0].naturalWidth || media.$node[0].videoWidth || media.$node[0].width,
320
- height: media.$node[0].naturalHeight || media.$node[0].videoHeight || media.$node[0].height
321
- };
322
- }
319
+ var mediaDimensionComponent = component({
323
320
  /**
324
- * Current component
321
+ * Reset the component to the initial state
322
+ * @returns {component} this
325
323
  */
324
+ reset: function reset() {
325
+ var syncDim = initialConfig.syncDimensions;
326
326
 
327
+ if (this.is('rendered')) {
328
+ // revert the sizes to the original
329
+ var originalSize = getOriginalSize();
330
+ initialConfig.sizeProps.px.current.width = originalSize.width;
331
+ initialConfig.sizeProps.px.current.height = originalSize.height;
332
+ initialConfig.sizeProps.ratio.current = initialConfig.sizeProps.ratio.natural; // reset needs to restore everything
327
333
 
328
- const mediaDimensionComponent = component({
329
- /**
330
- * Reset the component to the initial state
331
- * @returns {component} this
332
- */
333
- reset: function reset() {
334
- const syncDim = initialConfig.syncDimensions;
335
-
336
- if (this.is('rendered')) {
337
- // revert the sizes to the original
338
- const originalSize = getOriginalSize();
339
- initialConfig.sizeProps.px.current.width = originalSize.width;
340
- initialConfig.sizeProps.px.current.height = originalSize.height;
341
- initialConfig.sizeProps.ratio.current = initialConfig.sizeProps.ratio.natural; // reset needs to restore everything
342
-
343
- initialConfig.syncDimensions = true; // apply changes
344
-
345
- initialConfig = calculateCurrentSizes(initialConfig);
346
- mediaDimensionComponent.update(); // restore current mode
347
-
348
- initialConfig.syncDimensions = syncDim; // trigger event
334
+ initialConfig.syncDimensions = true; // apply changes
349
335
 
350
- this.trigger('reset', initialConfig);
351
- }
336
+ initialConfig = calculateCurrentSizes(initialConfig);
337
+ mediaDimensionComponent.update(); // restore current mode
352
338
 
353
- return this;
354
- },
339
+ initialConfig.syncDimensions = syncDim; // trigger event
355
340
 
356
- /**
357
- * Apply configurations to the view
358
- */
359
- update: function update() {
360
- // slide sliders
361
- $slider.val(initialConfig.sizeProps['%'].current.width); // percent Input
341
+ this.trigger('reset', initialConfig);
342
+ }
362
343
 
363
- $fields['%'].width.val(Math.round(initialConfig.sizeProps['%'].current.width)); // px inputs
344
+ return this;
345
+ },
364
346
 
365
- $fields.px.width.val(Math.round(initialConfig.sizeProps.px.current.width));
366
- $fields.px.height.val(Math.round(initialConfig.sizeProps.px.current.height));
367
- this.trigger('change', initialConfig);
368
- }
369
- }, defaultConfig);
370
347
  /**
371
- * Check that input in progress and we don't need to change anything
372
- * @param {String|number} val
373
- * @returns {RegExpMatchArray | null}
348
+ * Apply configurations to the view
374
349
  */
350
+ update: function update() {
351
+ // slide sliders
352
+ $slider.val(initialConfig.sizeProps['%'].current.width); // percent Input
375
353
 
376
- const isInsignificantEnd = function isInsignificantEnd(val) {
377
- if (typeof val !== 'string') {
378
- val = `${val}`;
379
- }
354
+ $fields['%'].width.val(Math.round(initialConfig.sizeProps['%'].current.width)); // px inputs
380
355
 
381
- return val.match(/\.[0]*$/);
382
- };
383
- /**
384
- * Blocks are the two different parts of the form (either width|height or size)
385
- *
386
- * @param {jQueryElement} $elt
387
- * @returns {{}}
388
- * @private
389
- */
356
+ $fields.px.width.val(Math.round(initialConfig.sizeProps.px.current.width));
357
+ $fields.px.height.val(Math.round(initialConfig.sizeProps.px.current.height));
358
+ this.trigger('change', initialConfig);
359
+ }
360
+ }, defaultConfig);
361
+ /**
362
+ * Check that input in progress and we don't need to change anything
363
+ * @param {String|number} val
364
+ * @returns {RegExpMatchArray | null}
365
+ */
390
366
 
367
+ var isInsignificantEnd = function isInsignificantEnd(val) {
368
+ if (typeof val !== 'string') {
369
+ val = "".concat(val);
370
+ }
391
371
 
392
- const initBlocks = function initBlocks($elt) {
393
- const _blocks = {},
394
- $responsiveToggleField = $elt.find('.media-mode-switch'),
395
- checkMode = function checkMode() {
396
- if ($responsiveToggleField.is(':checked')) {
397
- initialConfig.responsive = true;
372
+ return val.match(/\.[0]*$/);
373
+ };
374
+ /**
375
+ * Blocks are the two different parts of the form (either width|height or size)
376
+ *
377
+ * @param {jQueryElement} $elt
378
+ * @returns {{}}
379
+ * @private
380
+ */
398
381
 
399
- _blocks.px.hide();
400
382
 
401
- _blocks['%'].show();
383
+ var initBlocks = function initBlocks($elt) {
384
+ var _blocks = {},
385
+ $responsiveToggleField = $elt.find('.media-mode-switch'),
386
+ checkMode = function checkMode() {
387
+ if ($responsiveToggleField.is(':checked')) {
388
+ initialConfig.responsive = true;
402
389
 
403
- initialConfig.sizeProps.currentUtil = '%';
404
- } else {
405
- initialConfig.responsive = false;
390
+ _blocks.px.hide();
406
391
 
407
- _blocks['%'].hide();
392
+ _blocks['%'].show();
408
393
 
409
- _blocks.px.show();
394
+ initialConfig.sizeProps.currentUtil = '%';
395
+ } else {
396
+ initialConfig.responsive = false;
410
397
 
411
- initialConfig.sizeProps.currentUtil = 'px';
412
- }
398
+ _blocks['%'].hide();
413
399
 
414
- if ($fields) {
415
- if ($fields['%'].width.val() > $slider.max) {
416
- $fields['%'].width.val($slider.max);
417
- }
400
+ _blocks.px.show();
418
401
 
419
- initialConfig = helper.applyDimensions(initialConfig, {
420
- percent: $fields['%'].width.val(),
421
- maxWidth: helper.getMediaContainerWidth(media)
422
- });
423
- mediaDimensionComponent.update();
402
+ initialConfig.sizeProps.currentUtil = 'px';
403
+ }
404
+
405
+ if ($fields) {
406
+ if ($fields['%'].width.val() > $slider.max) {
407
+ $fields['%'].width.val($slider.max);
424
408
  }
425
- };
426
409
 
427
- if (!initialConfig.showResponsiveToggle) {
428
- $elt.addClass('media-sizer-responsivetoggle-off');
410
+ initialConfig = helper.applyDimensions(initialConfig, {
411
+ percent: $fields['%'].width.val(),
412
+ maxWidth: helper.getMediaContainerWidth(media)
413
+ });
414
+ mediaDimensionComponent.update();
429
415
  }
416
+ };
430
417
 
431
- _(['px', '%']).forEach(function (unit) {
432
- _blocks[unit] = $elt.find(`.media-sizer-${unit === 'px' ? 'pixel' : 'percent'}`);
418
+ if (!initialConfig.showResponsiveToggle) {
419
+ $elt.addClass('media-sizer-responsivetoggle-off');
420
+ }
433
421
 
434
- _blocks[unit].prop('unit', unit);
422
+ _(['px', '%']).forEach(function (unit) {
423
+ _blocks[unit] = $elt.find(".media-sizer-".concat(unit === 'px' ? 'pixel' : 'percent'));
435
424
 
436
- _blocks[unit].find('input').data('unit', unit);
437
- });
425
+ _blocks[unit].prop('unit', unit);
438
426
 
439
- $responsiveToggleField.on('click', function () {
440
- checkMode();
441
- });
442
- $responsiveToggleField.prop('checked', initialConfig.responsive); // initialize it properly
427
+ _blocks[unit].find('input').data('unit', unit);
428
+ });
443
429
 
430
+ $responsiveToggleField.on('click', function () {
444
431
  checkMode();
445
- return _blocks;
446
- };
447
- /**
448
- * Toggle width/height synchronization
449
- *
450
- * @param {jQueryElement} $elt
451
- * @returns {*}
452
- * @private
453
- */
454
-
432
+ });
433
+ $responsiveToggleField.prop('checked', initialConfig.responsive); // initialize it properly
455
434
 
456
- const initSyncBtn = function initSyncBtn($elt) {
457
- const $mediaSizer = $elt.find('.media-sizer'),
458
- $btn = $elt.find('.media-sizer-sync');
435
+ checkMode();
436
+ return _blocks;
437
+ };
438
+ /**
439
+ * Toggle width/height synchronization
440
+ *
441
+ * @param {jQueryElement} $elt
442
+ * @returns {*}
443
+ * @private
444
+ */
459
445
 
460
- if (!initialConfig.showSync) {
461
- $btn.hide();
462
- $mediaSizer.addClass('media-sizer-sync-off');
463
- } // this stays intact even if hidden in case it will be
464
- // displayed from somewhere else
465
446
 
447
+ var initSyncBtn = function initSyncBtn($elt) {
448
+ var $mediaSizer = $elt.find('.media-sizer'),
449
+ $btn = $elt.find('.media-sizer-sync');
466
450
 
467
- $btn.on('click', function () {
468
- const $sizerEl = $$1(this).parents('.media-sizer');
469
- $sizerEl.toggleClass('media-sizer-synced');
470
- initialConfig.syncDimensions = $sizerEl.hasClass('media-sizer-synced');
471
- });
472
- return $btn;
473
- };
474
- /**
475
- * Button to reset the size to its original values
476
- *
477
- * @param {jQueryElement} $elt
478
- * @returns {*}
479
- * @private
480
- */
451
+ if (!initialConfig.showSync) {
452
+ $btn.hide();
453
+ $mediaSizer.addClass('media-sizer-sync-off');
454
+ } // this stays intact even if hidden in case it will be
455
+ // displayed from somewhere else
481
456
 
482
457
 
483
- const initResetBtn = function initResetBtn($elt) {
484
- const $btn = $elt.find('.media-sizer-reset');
458
+ $btn.on('click', function () {
459
+ var $sizerEl = $$1(this).parents('.media-sizer');
460
+ $sizerEl.toggleClass('media-sizer-synced');
461
+ initialConfig.syncDimensions = $sizerEl.hasClass('media-sizer-synced');
462
+ });
463
+ return $btn;
464
+ };
465
+ /**
466
+ * Button to reset the size to its original values
467
+ *
468
+ * @param {jQueryElement} $elt
469
+ * @returns {*}
470
+ * @private
471
+ */
485
472
 
486
- if (!initialConfig.showReset) {
487
- $elt.find('.media-sizer').addClass('media-sizer-reset-off');
488
- } // this stays intact even if hidden in case it will be
489
- // displayed from somewhere else
490
473
 
474
+ var initResetBtn = function initResetBtn($elt) {
475
+ var $btn = $elt.find('.media-sizer-reset');
491
476
 
492
- $btn.on('click', function (e) {
493
- e.preventDefault();
494
- mediaDimensionComponent.reset();
495
- return false;
496
- });
497
- return $btn;
498
- };
499
- /**
500
- * Initialize the fields
501
- *
502
- * @returns {{}}
503
- * @private
504
- */
477
+ if (!initialConfig.showReset) {
478
+ $elt.find('.media-sizer').addClass('media-sizer-reset-off');
479
+ } // this stays intact even if hidden in case it will be
480
+ // displayed from somewhere else
505
481
 
506
482
 
507
- const initFields = function initFields() {
508
- const dimensions = ['width', 'height'];
509
- let field;
510
- const _fields = {};
483
+ $btn.on('click', function (e) {
484
+ e.preventDefault();
485
+ mediaDimensionComponent.reset();
486
+ return false;
487
+ });
488
+ return $btn;
489
+ };
490
+ /**
491
+ * Initialize the fields
492
+ *
493
+ * @returns {{}}
494
+ * @private
495
+ */
511
496
 
512
- _($blocks).forOwn(function ($block, unit) {
513
- _fields[unit] = {};
514
- $blocks[unit].find('input').each(function () {
515
- _(dimensions).forEach(function (dim) {
516
- field = $blocks[unit].find(`[name="${dim}"]`); // there is no 'height' field for % - $('<input>') is a dummy to avoid checking if the field exists all the time
517
497
 
518
- _fields[unit][dim] = field.length ? field : $$1('<input>');
498
+ var initFields = function initFields() {
499
+ var dimensions = ['width', 'height'];
500
+ var field;
501
+ var _fields = {};
519
502
 
520
- _fields[unit][dim].prop({
521
- unit: unit,
522
- dimension: dim
523
- });
503
+ _($blocks).forOwn(function ($block, unit) {
504
+ _fields[unit] = {};
505
+ $blocks[unit].find('input').each(function () {
506
+ _(dimensions).forEach(function (dim) {
507
+ field = $blocks[unit].find("[name=\"".concat(dim, "\"]")); // there is no 'height' field for % - $('<input>') is a dummy to avoid checking if the field exists all the time
524
508
 
525
- _fields[unit][dim].val(initialConfig.sizeProps[unit].current[dim]);
509
+ _fields[unit][dim] = field.length ? field : $$1('<input>');
526
510
 
527
- _fields[unit][dim].on('keydown', function (e) {
528
- const $field = $$1(this),
529
- c = e.keyCode,
530
- specChars = function () {
531
- const chars = [8, 37, 39, 46];
511
+ _fields[unit][dim].prop({
512
+ unit: unit,
513
+ dimension: dim
514
+ });
532
515
 
533
- if ($field.val().indexOf('.') === -1) {
534
- chars.push(190);
535
- chars.push(110);
536
- }
516
+ _fields[unit][dim].val(initialConfig.sizeProps[unit].current[dim]);
537
517
 
538
- return chars;
539
- }(),
540
- allowed = _.contains(specChars, c) || c >= 48 && c <= 57 || c >= 96 && c <= 105;
518
+ _fields[unit][dim].on('keydown', function (e) {
519
+ var $field = $$1(this),
520
+ c = e.keyCode,
521
+ specChars = function () {
522
+ var chars = [8, 37, 39, 46];
541
523
 
542
- if (!allowed) {
543
- e.preventDefault();
524
+ if ($field.val().indexOf('.') === -1) {
525
+ chars.push(190);
526
+ chars.push(110);
544
527
  }
545
528
 
546
- return allowed;
547
- });
548
-
549
- _fields[unit][dim].on('keyup blur sliderchange', function () {
550
- const $field = $$1(this);
551
- let value = $field.val().replace(/,/g, '.');
552
- let newDimensions;
553
- $field.val(value);
529
+ return chars;
530
+ }(),
531
+ allowed = _.contains(specChars, c) || c >= 48 && c <= 57 || c >= 96 && c <= 105;
554
532
 
555
- if (isInsignificantEnd(value)) {
556
- // do nothing if .00 or something insignificant at the end of line
557
- return;
558
- }
533
+ if (!allowed) {
534
+ e.preventDefault();
535
+ }
559
536
 
560
- if (value > $field.data('max')) {
561
- $field.val($field.data('max'));
562
- value = `${$field.data('max')}`;
563
- } else if (value < $field.data('min')) {
564
- $field.val($field.data('min'));
565
- value = `${$field.data('min')}`;
566
- }
537
+ return allowed;
538
+ });
567
539
 
568
- if ($field.prop('unit') === '%') {
569
- initialConfig.sizeProps['%'].current.width = value;
540
+ _fields[unit][dim].on('keyup blur sliderchange', function () {
541
+ var $field = $$1(this);
542
+ var value = $field.val().replace(/,/g, '.');
543
+ var newDimensions;
544
+ $field.val(value);
545
+
546
+ if (isInsignificantEnd(value)) {
547
+ // do nothing if .00 or something insignificant at the end of line
548
+ return;
549
+ }
550
+
551
+ if (value > $field.data('max')) {
552
+ $field.val($field.data('max'));
553
+ value = "".concat($field.data('max'));
554
+ } else if (value < $field.data('min')) {
555
+ $field.val($field.data('min'));
556
+ value = "".concat($field.data('min'));
557
+ }
558
+
559
+ if ($field.prop('unit') === '%') {
560
+ initialConfig.sizeProps['%'].current.width = value;
561
+ newDimensions = {
562
+ percent: value
563
+ };
564
+ } else {
565
+ if ($field.prop('dimension') === 'height') {
570
566
  newDimensions = {
571
- percent: value
567
+ height: value
572
568
  };
573
569
  } else {
574
- if ($field.prop('dimension') === 'height') {
575
- newDimensions = {
576
- height: value
577
- };
578
- } else {
579
- newDimensions = {
580
- width: value
581
- };
582
- }
570
+ newDimensions = {
571
+ width: value
572
+ };
583
573
  }
574
+ }
584
575
 
585
- newDimensions.maxWidth = helper.getMediaContainerWidth(media);
586
- initialConfig = helper.applyDimensions(initialConfig, newDimensions);
587
- mediaDimensionComponent.update();
588
- });
576
+ newDimensions.maxWidth = helper.getMediaContainerWidth(media);
577
+ initialConfig = helper.applyDimensions(initialConfig, newDimensions);
578
+ mediaDimensionComponent.update();
589
579
  });
590
580
  });
591
581
  });
582
+ });
592
583
 
593
- return _fields;
594
- };
595
- /**
596
- * Initialize the two sliders, one based on pixels the other on percentage
597
- *
598
- * @param {jQueryElement} $elt
599
- * @returns {{}}
600
- * @private
601
- */
584
+ return _fields;
585
+ };
586
+ /**
587
+ * Initialize the two sliders, one based on pixels the other on percentage
588
+ *
589
+ * @param {jQueryElement} $elt
590
+ * @returns {{}}
591
+ * @private
592
+ */
602
593
 
603
594
 
604
- const initSlider = function initSlider($elt) {
605
- let slider;
606
- slider = $elt.find('.media-sizer-slider');
607
- slider.prop('unit', '%');
608
- slider.noUiSlider({
609
- start: initialConfig.sizeProps.slider.start,
610
- range: {
611
- min: initialConfig.sizeProps.slider.min,
612
- max: initialConfig.sizeProps.slider.max
613
- }
614
- }).on('slide', function () {
615
- // to avoid .00
616
- const percent = parseFloat(`${$$1(this).val()}`);
617
- helper.applyDimensions(initialConfig, {
618
- percent: percent,
619
- maxWidth: helper.getMediaContainerWidth(media)
620
- });
621
- mediaDimensionComponent.update();
595
+ var initSlider = function initSlider($elt) {
596
+ var slider;
597
+ slider = $elt.find('.media-sizer-slider');
598
+ slider.prop('unit', '%');
599
+ slider.noUiSlider({
600
+ start: initialConfig.sizeProps.slider.start,
601
+ range: {
602
+ min: initialConfig.sizeProps.slider.min,
603
+ max: initialConfig.sizeProps.slider.max
604
+ }
605
+ }).on('slide', function () {
606
+ // to avoid .00
607
+ var percent = parseFloat("".concat($$1(this).val()));
608
+ helper.applyDimensions(initialConfig, {
609
+ percent: percent,
610
+ maxWidth: helper.getMediaContainerWidth(media)
622
611
  });
623
- return slider;
624
- };
612
+ mediaDimensionComponent.update();
613
+ });
614
+ return slider;
615
+ };
625
616
 
626
- mediaDimensionComponent.on('init', function () {
627
- const originalSize = getOriginalSize();
628
- const naturalWidth = originalSize.width;
629
- const naturalHeight = originalSize.height;
630
- const mediaProps = {
631
- px: {
632
- current: {
633
- width: media.width,
634
- height: media.height
635
- },
636
- natural: {
637
- width: naturalWidth ? naturalWidth : media.width,
638
- height: naturalHeight ? naturalHeight : media.height
639
- }
617
+ mediaDimensionComponent.on('init', function () {
618
+ var originalSize = getOriginalSize();
619
+ var naturalWidth = originalSize.width;
620
+ var naturalHeight = originalSize.height;
621
+ var mediaProps = {
622
+ px: {
623
+ current: {
624
+ width: media.width,
625
+ height: media.height
640
626
  },
641
- '%': {
642
- current: {
643
- width: 100
644
- }
627
+ natural: {
628
+ width: naturalWidth ? naturalWidth : media.width,
629
+ height: naturalHeight ? naturalHeight : media.height
630
+ }
631
+ },
632
+ '%': {
633
+ current: {
634
+ width: 100
645
635
  }
646
- }; // rewrite with defined values
647
-
648
- initialConfig = this.getConfig();
649
- initialConfig.sizeProps = _.defaults(mediaProps, initialConfig.sizeProps, defaultConfig.sizeProps);
650
- initialConfig.sizeProps.ratio.natural = helper.round(initialConfig.sizeProps.px.natural.width / initialConfig.sizeProps.px.natural.height, initialConfig.precision);
651
- initialConfig.responsive = typeof initialConfig.responsive !== 'undefined' ? initialConfig.responsive : true;
652
- initialConfig.sizeProps.currentUtil = initialConfig.responsive ? '%' : 'px';
653
- this.render($container);
654
- }).on('render', function () {
655
- let $mediaSizer;
656
- initialConfig = this.getConfig();
657
- $template = $$1(tpl({
658
- responsive: initialConfig.responsive
659
- }));
660
- $template.appendTo(this.getContainer());
661
- $mediaSizer = $template.find('.media-sizer');
662
-
663
- if (initialConfig.syncDimensions === true && !$mediaSizer.hasClass('media-sizer-synced')) {
664
- $mediaSizer.addClass('media-sizer-synced');
665
636
  }
637
+ }; // rewrite with defined values
638
+
639
+ initialConfig = this.getConfig();
640
+ initialConfig.sizeProps = _.defaults(mediaProps, initialConfig.sizeProps, defaultConfig.sizeProps);
641
+ initialConfig.sizeProps.ratio.natural = helper.round(initialConfig.sizeProps.px.natural.width / initialConfig.sizeProps.px.natural.height, initialConfig.precision);
642
+ initialConfig.responsive = typeof initialConfig.responsive !== 'undefined' ? initialConfig.responsive : true;
643
+ initialConfig.sizeProps.currentUtil = initialConfig.responsive ? '%' : 'px';
644
+ this.render($container);
645
+ }).on('render', function () {
646
+ var $mediaSizer;
647
+ initialConfig = this.getConfig();
648
+ $template = $$1(tpl({
649
+ responsive: initialConfig.responsive
650
+ }));
651
+ $template.appendTo(this.getContainer());
652
+ $mediaSizer = $template.find('.media-sizer');
653
+
654
+ if (initialConfig.syncDimensions === true && !$mediaSizer.hasClass('media-sizer-synced')) {
655
+ $mediaSizer.addClass('media-sizer-synced');
656
+ }
666
657
 
667
- $blocks = initBlocks($template);
668
- $slider = initSlider($template);
669
- $fields = initFields();
670
- initSyncBtn($template);
671
- initResetBtn($template);
672
-
673
- if (typeof media.width === 'undefined') {
674
- // if sizes are not set then control panel initialization
675
- initialConfig = calculateCurrentSizes(initialConfig);
658
+ $blocks = initBlocks($template);
659
+ $slider = initSlider($template);
660
+ $fields = initFields();
661
+ initSyncBtn($template);
662
+ initResetBtn($template);
663
+
664
+ if (typeof media.width === 'undefined') {
665
+ // if sizes are not set then control panel initialization
666
+ initialConfig = calculateCurrentSizes(initialConfig);
667
+ } else {
668
+ if (initialConfig.responsive) {
669
+ // initialize by percent on the responsive mode
670
+ initialConfig = helper.applyDimensions(initialConfig, {
671
+ percent: media.width,
672
+ maxWidth: helper.getMediaContainerWidth(media)
673
+ });
676
674
  } else {
677
- if (initialConfig.responsive) {
678
- // initialize by percent on the responsive mode
679
- initialConfig = helper.applyDimensions(initialConfig, {
680
- percent: media.width,
681
- maxWidth: helper.getMediaContainerWidth(media)
682
- });
683
- } else {
684
- // non-responsive mode
685
- initialConfig.sizeProps.px.current = {
686
- width: media.width,
687
- height: media.height
688
- }; // calculate percent
689
-
690
- initialConfig.sizeProps['%'].current.width = helper.round(media.width * 100 / helper.getMediaContainerWidth(media), initialConfig.precision);
691
- }
675
+ // non-responsive mode
676
+ initialConfig.sizeProps.px.current = {
677
+ width: media.width,
678
+ height: media.height
679
+ }; // calculate percent
680
+
681
+ initialConfig.sizeProps['%'].current.width = helper.round(media.width * 100 / helper.getMediaContainerWidth(media), initialConfig.precision);
692
682
  }
683
+ }
693
684
 
694
- mediaDimensionComponent.update();
695
- }).on('destroy', function () {
696
- $template.remove();
697
- });
685
+ mediaDimensionComponent.update();
686
+ }).on('destroy', function () {
687
+ $template.remove();
688
+ });
698
689
 
699
- _.defer(function () {
700
- mediaDimensionComponent.init(config);
701
- });
690
+ _.defer(function () {
691
+ mediaDimensionComponent.init(config);
692
+ });
702
693
 
703
- return mediaDimensionComponent;
704
- }
694
+ return mediaDimensionComponent;
695
+ }
705
696
 
706
- return mediaDimensionFactory;
697
+ return mediaDimensionFactory;
707
698
 
708
699
  });