@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,768 +1,759 @@
1
1
  define(['jquery', 'lodash', 'core/pluginifier', 'handlebars', 'i18n', 'lib/dompurify/purify', 'nouislider', 'ui/tooltip'], function ($$1, _, Pluginifier, Handlebars, __, DOMPurify, nouislider, tooltip) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- Pluginifier = Pluginifier && Object.prototype.hasOwnProperty.call(Pluginifier, 'default') ? Pluginifier['default'] : Pluginifier;
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
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ Pluginifier = Pluginifier && Object.prototype.hasOwnProperty.call(Pluginifier, 'default') ? Pluginifier['default'] : Pluginifier;
6
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
7
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
8
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
9
+
10
+ function _typeof(obj) {
11
+ "@babel/helpers - typeof";
12
+
13
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14
+ return typeof obj;
15
+ } : function (obj) {
16
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17
+ }, _typeof(obj);
18
+ }
19
+
20
+ function Helpers0 (hb) {
21
+ //register a i18n helper
22
+ hb.registerHelper('__', function (key) {
23
+ return __(key);
24
+ });
10
25
  /**
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License
13
- * as published by the Free Software Foundation; under version 2
14
- * of the License (non-upgradable).
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
- *
25
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
26
- *
26
+ * Register dompurify helper
27
27
  *
28
+ * https://github.com/cure53/DOMPurify
29
+ * with config SAFE_FOR_TEMPLATES: true
30
+ * to make output safe for template systems
28
31
  */
29
- function Helpers0 (hb) {
30
- //register a i18n helper
31
- hb.registerHelper('__', function (key) {
32
- return __(key);
33
- });
34
- /**
35
- * Register dompurify helper
36
- *
37
- * https://github.com/cure53/DOMPurify
38
- * with config SAFE_FOR_TEMPLATES: true
39
- * to make output safe for template systems
40
- */
41
-
42
- hb.registerHelper('dompurify', function (context) {
43
- return DOMPurify.sanitize(context);
44
- });
45
- /**
46
- * Register join helper
47
- *
48
- * Example :
49
- * var values = {a:v1, b:v2, c:v3};
50
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
51
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
52
- */
53
-
54
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
55
- var fragments = [];
56
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
57
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
58
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
59
-
60
- _.forIn(arr, function (value, key) {
61
- var fragment = '';
62
-
63
- if (value !== null || value !== undefined) {
64
- if (typeof value === 'boolean') {
65
- value = value ? 'true' : 'false';
66
- } else if (typeof value === 'object') {
67
- value = _.values(value).join(' ');
68
- }
69
- } else {
70
- value = '';
71
- }
72
32
 
73
- if (keyValueGlue !== undefined) {
74
- fragment += key + keyValueGlue;
75
- }
33
+ hb.registerHelper('dompurify', function (context) {
34
+ return DOMPurify.sanitize(context);
35
+ });
36
+ /**
37
+ * Register join helper
38
+ *
39
+ * Example :
40
+ * var values = {a:v1, b:v2, c:v3};
41
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
42
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
43
+ */
76
44
 
77
- fragment += wrapper + value + wrapper;
78
- fragments.push(fragment);
79
- });
45
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
46
+ var fragments = [];
47
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
48
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
49
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
80
50
 
81
- return fragments.join(fragmentGlue);
82
- }); //register a classic "for loop" helper
83
- //it also adds a local variable "i" as the index in each iteration loop
51
+ _.forIn(arr, function (value, key) {
52
+ var fragment = '';
84
53
 
85
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
86
- var ret = '';
87
- startIndex = parseInt(startIndex);
88
- stopIndex = parseInt(stopIndex);
89
- increment = parseInt(increment);
54
+ if (value !== null || value !== undefined) {
55
+ if (typeof value === 'boolean') {
56
+ value = value ? 'true' : 'false';
57
+ } else if (_typeof(value) === 'object') {
58
+ value = _.values(value).join(' ');
59
+ }
60
+ } else {
61
+ value = '';
62
+ }
90
63
 
91
- for (var i = startIndex; i < stopIndex; i += increment) {
92
- ret += options.fn(_.extend({}, this, {
93
- i: i
94
- }));
64
+ if (keyValueGlue !== undefined) {
65
+ fragment += key + keyValueGlue;
95
66
  }
96
67
 
97
- return ret;
68
+ fragment += wrapper + value + wrapper;
69
+ fragments.push(fragment);
98
70
  });
99
- hb.registerHelper('equal', function (var1, var2, options) {
100
- if (var1 == var2) {
101
- return options.fn(this);
102
- } else {
103
- return options.inverse(this);
104
- }
105
- }); // register a "get property" helper
106
- // it gets the named property from the provided context
107
71
 
108
- hb.registerHelper('property', function (name, context) {
109
- return context[name] || '';
110
- }); // register an 'includes' helper
111
- // it checks if value is in array
72
+ return fragments.join(fragmentGlue);
73
+ }); //register a classic "for loop" helper
74
+ //it also adds a local variable "i" as the index in each iteration loop
112
75
 
113
- hb.registerHelper('includes', function (haystack, needle, options) {
114
- if (_.contains(haystack, needle)) {
115
- return options.fn(this);
116
- }
117
- });
118
- }
76
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
77
+ var ret = '';
78
+ startIndex = parseInt(startIndex);
79
+ stopIndex = parseInt(stopIndex);
80
+ increment = parseInt(increment);
119
81
 
120
- if (!Helpers0.__initialized) {
121
- Helpers0(Handlebars);
122
- Helpers0.__initialized = true;
123
- }
124
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
125
- this.compilerInfo = [4,'>= 1.0.0'];
126
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
127
- var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
128
-
129
- function program1(depth0,data) {
130
-
131
-
132
- return "checked=\"checked\"";
82
+ for (var i = startIndex; i < stopIndex; i += increment) {
83
+ ret += options.fn(_.extend({}, this, {
84
+ i: i
85
+ }));
133
86
  }
134
87
 
135
- buffer += "<div class=\"media-sizer media-sizer-synced\">\n\n <div class=\"media-sizer-responsive-toggle\">\n <label>\n <input type=\"checkbox\" ";
136
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.responsive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
137
- if(stack1 || stack1 === 0) { buffer += stack1; }
138
- buffer += " class=\"media-mode-switch\"/>\n <span class=\"icon-checkbox\"></span>\n "
139
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Responsive mode", options) : helperMissing.call(depth0, "__", "Responsive mode", options)))
140
- + "\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 "
141
- + 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)))
142
- + "\n </div>\n </div>\n\n\n <div class=\"media-sizer-percent\">\n <label for=\"media-sizer-percent-width\">"
143
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Size", options) : helperMissing.call(depth0, "__", "Size", options)))
144
- + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-percent-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\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 <label for=\"media-sizer-pixel-width\">"
145
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Width", options) : helperMissing.call(depth0, "__", "Width", options)))
146
- + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-pixel-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n </span>\n\n <label for=\"media-sizer-pixel-height\">"
147
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Height", options) : helperMissing.call(depth0, "__", "Height", options)))
148
- + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"height\" id=\"media-sizer-pixel-height\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n </span>\n\n <div class=\"media-sizer-sync\">\n <span class=\"icon-link\"></span>\n </div>\n\n <div class=\"media-sizer-reset media-sizer-reset-pixel\" data-unit=\"pixel\">\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 class=\"media-sizer-cover\"></div>\n </div>\n </div>\n</div>";
149
- return buffer;
150
- });
151
- function tpl(data, options, asString) {
152
- var html = Template(data, options);
153
- return (asString || true) ? html : $(html);
88
+ return ret;
89
+ });
90
+ hb.registerHelper('equal', function (var1, var2, options) {
91
+ if (var1 == var2) {
92
+ return options.fn(this);
93
+ } else {
94
+ return options.inverse(this);
95
+ }
96
+ }); // register a "get property" helper
97
+ // it gets the named property from the provided context
98
+
99
+ hb.registerHelper('property', function (name, context) {
100
+ return context[name] || '';
101
+ }); // register an 'includes' helper
102
+ // it checks if value is in array
103
+
104
+ hb.registerHelper('includes', function (haystack, needle, options) {
105
+ if (_.contains(haystack, needle)) {
106
+ return options.fn(this);
107
+ }
108
+ });
109
+ }
110
+
111
+ if (!Helpers0.__initialized) {
112
+ Helpers0(Handlebars);
113
+ Helpers0.__initialized = true;
114
+ }
115
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
116
+ this.compilerInfo = [4,'>= 1.0.0'];
117
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
118
+ var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
119
+
120
+ function program1(depth0,data) {
121
+
122
+
123
+ return "checked=\"checked\"";
154
124
  }
155
125
 
156
- /*
157
- * This program is free software; you can redistribute it and/or
158
- * modify it under the terms of the GNU General Public License
159
- * as published by the Free Software Foundation; under version 2
160
- * of the License (non-upgradable).
161
- *
162
- * This program is distributed in the hope that it will be useful,
163
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
164
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
165
- * GNU General Public License for more details.
166
- *
167
- * You should have received a copy of the GNU General Public License
168
- * along with this program; if not, write to the Free Software
169
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
170
- *
171
- * Copyright (c) 2015 (original work) Open Assessment Technologies SA;
172
- *
173
- */
174
- var ns = 'mediasizer';
175
- var dataNs = 'ui.' + ns;
176
- var MediaSizer;
126
+ buffer += "<div class=\"media-sizer media-sizer-synced\">\n\n <div class=\"media-sizer-responsive-toggle\">\n <label>\n <input type=\"checkbox\" ";
127
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.responsive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
128
+ if(stack1 || stack1 === 0) { buffer += stack1; }
129
+ buffer += " class=\"media-mode-switch\"/>\n <span class=\"icon-checkbox\"></span>\n "
130
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Responsive mode", options) : helperMissing.call(depth0, "__", "Responsive mode", options)))
131
+ + "\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 "
132
+ + 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)))
133
+ + "\n </div>\n </div>\n\n\n <div class=\"media-sizer-percent\">\n <label for=\"media-sizer-percent-width\">"
134
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Size", options) : helperMissing.call(depth0, "__", "Size", options)))
135
+ + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-percent-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\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 <label for=\"media-sizer-pixel-width\">"
136
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Width", options) : helperMissing.call(depth0, "__", "Width", options)))
137
+ + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"width\" id=\"media-sizer-pixel-width\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n </span>\n\n <label for=\"media-sizer-pixel-height\">"
138
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Height", options) : helperMissing.call(depth0, "__", "Height", options)))
139
+ + "</label>\n <span class=\"item-editor-unit-input-box\">\n <input type=\"text\" name=\"height\" id=\"media-sizer-pixel-height\" data-validate=\"$numeric\" data-validate-option=\"$allowEmpty;\"/>\n </span>\n\n <div class=\"media-sizer-sync\">\n <span class=\"icon-link\"></span>\n </div>\n\n <div class=\"media-sizer-reset media-sizer-reset-pixel\" data-unit=\"pixel\">\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 class=\"media-sizer-cover\"></div>\n </div>\n </div>\n</div>";
140
+ return buffer;
141
+ });
142
+ function tpl(data, options, asString) {
143
+ var html = Template(data, options);
144
+ return (asString || true) ? html : $(html);
145
+ }
146
+
147
+ /*
148
+ * This program is free software; you can redistribute it and/or
149
+ * modify it under the terms of the GNU General Public License
150
+ * as published by the Free Software Foundation; under version 2
151
+ * of the License (non-upgradable).
152
+ *
153
+ * This program is distributed in the hope that it will be useful,
154
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
155
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
156
+ * GNU General Public License for more details.
157
+ *
158
+ * You should have received a copy of the GNU General Public License
159
+ * along with this program; if not, write to the Free Software
160
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
161
+ *
162
+ * Copyright (c) 2015 (original work) Open Assessment Technologies SA;
163
+ *
164
+ */
165
+ var ns = 'mediasizer';
166
+ var dataNs = 'ui.' + ns;
167
+ var MediaSizer;
168
+ /**
169
+ * default setup
170
+ *
171
+ * optional values are:
172
+ * width | naturalWidth (alias)
173
+ * height | naturalHeight (alias)
174
+ * maxWidth
175
+ * parentSelector
176
+ *
177
+ * @type {Object}
178
+ */
179
+
180
+ var defaults = {
181
+ disableClass: 'disabled',
182
+ applyToMedium: true,
183
+ denyCustomRatio: true,
184
+ responsive: true,
185
+ showResponsiveToggle: true,
186
+ showReset: true,
187
+ showSync: true,
188
+ size: 100
189
+ };
190
+ /**
191
+ * Round a decimal value to n digits
192
+ *
193
+ * @param {number} value
194
+ * @param {int} precision
195
+ * @returns {number}
196
+ * @private
197
+ */
198
+
199
+ function _round(value, precision) {
200
+ var factor = Math.pow(10, precision);
201
+ return Math.round(value * factor) / factor;
202
+ }
203
+ /**
204
+ * The MediaSizer component, that helps you to show/hide an element
205
+ * @exports ui/toggler
206
+ */
207
+
208
+
209
+ MediaSizer = {
177
210
  /**
178
- * default setup
179
- *
180
- * optional values are:
181
- * width | naturalWidth (alias)
182
- * height | naturalHeight (alias)
183
- * maxWidth
184
- * parentSelector
211
+ * Returns width, height, target element and the reset button
212
+ * It's meant to be used when triggering an event
185
213
  *
186
- * @type {Object}
214
+ * @param $elt
215
+ * @param options
216
+ * @returns {{}}
217
+ * @private
187
218
  */
219
+ _publicArgs: function _publicArgs($elt, options) {
220
+ var params = this._getValues($elt);
221
+
222
+ params.$target = options.target || $$1();
223
+ params.$resetBtn = options.$resetBtn;
224
+ return params;
225
+ },
188
226
 
189
- var defaults = {
190
- disableClass: 'disabled',
191
- applyToMedium: true,
192
- denyCustomRatio: true,
193
- responsive: true,
194
- showResponsiveToggle: true,
195
- showReset: true,
196
- showSync: true,
197
- size: 100
198
- };
199
227
  /**
200
- * Round a decimal value to n digits
228
+ * Creates object that contains all size related data of the medium (= image, video, etc.)
201
229
  *
202
- * @param {number} value
203
- * @param {int} precision
204
- * @returns {number}
230
+ * @param $elt
231
+ * @returns {{px: {natural: {width: (number|*), height: (number|*)}, current: {width: *, height: *}}, %: {natural: {width: number, height: null}, current: {width: number, height: null}}, ratio: {natural: number, current: number}, containerWidth: , sliders: {%: {min: number, max: number, start: number}, px: {min: number, max: number, start: *}}, currentUnit: string}}
205
232
  * @private
206
233
  */
234
+ _getSizeProps: function _getSizeProps($elt) {
235
+ var options = $elt.data(dataNs),
236
+ $medium,
237
+ naturalWidth,
238
+ naturalHeight,
239
+ containerWidth,
240
+ displaySize,
241
+ minWidth = _.isNumber(options.minWidth) ? options.minWidth : 0,
242
+ maxWidth;
243
+
244
+ if (options.hasTarget) {
245
+ $medium = options.target;
246
+ displaySize = $medium[0].getBoundingClientRect();
247
+ options.width = displaySize.width;
248
+ options.height = displaySize.height;
249
+ naturalWidth = $medium[0].naturalWidth || options.width;
250
+ naturalHeight = $medium[0].naturalHeight || options.height;
251
+
252
+ containerWidth = function () {
253
+ var $parentContainer = options.parentSelector ? $medium.parents(options.parentSelector) : $medium.parent().parent(),
254
+ _maxWidth;
255
+
256
+ if (options.maxWidth) {
257
+ return options.maxWidth;
258
+ }
207
259
 
208
- function _round(value, precision) {
209
- var factor = Math.pow(10, precision);
210
- return Math.round(value * factor) / factor;
211
- }
212
- /**
213
- * The MediaSizer component, that helps you to show/hide an element
214
- * @exports ui/toggler
215
- */
260
+ _maxWidth = $parentContainer.css('max-width');
216
261
 
262
+ if (_maxWidth !== 'none') {
263
+ return parseInt(_maxWidth);
264
+ }
217
265
 
218
- MediaSizer = {
219
- /**
220
- * Returns width, height, target element and the reset button
221
- * It's meant to be used when triggering an event
222
- *
223
- * @param $elt
224
- * @param options
225
- * @returns {{}}
226
- * @private
227
- */
228
- _publicArgs: function ($elt, options) {
229
- var params = this._getValues($elt);
230
-
231
- params.$target = options.target || $$1();
232
- params.$resetBtn = options.$resetBtn;
233
- return params;
234
- },
235
-
236
- /**
237
- * Creates object that contains all size related data of the medium (= image, video, etc.)
238
- *
239
- * @param $elt
240
- * @returns {{px: {natural: {width: (number|*), height: (number|*)}, current: {width: *, height: *}}, %: {natural: {width: number, height: null}, current: {width: number, height: null}}, ratio: {natural: number, current: number}, containerWidth: , sliders: {%: {min: number, max: number, start: number}, px: {min: number, max: number, start: *}}, currentUnit: string}}
241
- * @private
242
- */
243
- _getSizeProps: function ($elt) {
244
- var options = $elt.data(dataNs),
245
- $medium,
246
- naturalWidth,
247
- naturalHeight,
248
- containerWidth,
249
- displaySize,
250
- minWidth = _.isNumber(options.minWidth) ? options.minWidth : 0,
251
- maxWidth;
252
-
253
- if (options.hasTarget) {
254
- $medium = options.target;
255
- displaySize = $medium[0].getBoundingClientRect();
256
- options.width = displaySize.width;
257
- options.height = displaySize.height;
258
- naturalWidth = $medium[0].naturalWidth || options.width;
259
- naturalHeight = $medium[0].naturalHeight || options.height;
260
-
261
- containerWidth = function () {
262
- var $parentContainer = options.parentSelector ? $medium.parents(options.parentSelector) : $medium.parent().parent(),
263
- _maxWidth;
264
-
265
- if (options.maxWidth) {
266
- return options.maxWidth;
267
- }
268
-
269
- _maxWidth = $parentContainer.css('max-width');
270
-
271
- if (_maxWidth !== 'none') {
272
- return parseInt(_maxWidth);
273
- }
274
-
275
- return $parentContainer.innerWidth();
276
- }();
277
- } else {
278
- // init() already makes sure width and height exist at this point
279
- naturalWidth = options.width;
280
- naturalHeight = options.height;
281
- containerWidth = options.maxWidth || options.width;
282
- }
266
+ return $parentContainer.innerWidth();
267
+ }();
268
+ } else {
269
+ // init() already makes sure width and height exist at this point
270
+ naturalWidth = options.width;
271
+ naturalHeight = options.height;
272
+ containerWidth = options.maxWidth || options.width;
273
+ }
283
274
 
284
- maxWidth = Math.max(containerWidth, naturalWidth);
285
- return {
286
- px: {
287
- //original values for all media
288
- natural: {
289
- width: naturalWidth,
290
- height: naturalHeight
291
- },
292
- current: {
293
- width: options.width,
294
- height: options.height
295
- }
296
- },
297
- '%': {
298
- natural: {
299
- width: 100,
300
- height: null
301
- },
302
- current: {
303
- width: options.width * 100 / containerWidth,
304
- height: null // height does not work on % - this is just in case you have to loop or something
305
-
306
- }
275
+ maxWidth = Math.max(containerWidth, naturalWidth);
276
+ return {
277
+ px: {
278
+ //original values for all media
279
+ natural: {
280
+ width: naturalWidth,
281
+ height: naturalHeight
307
282
  },
308
- ratio: {
309
- natural: naturalWidth / naturalHeight,
310
- current: options.width / options.height
311
- },
312
- containerWidth: containerWidth,
313
- sliders: {
314
- '%': {
315
- min: minWidth * 100 / maxWidth,
316
- max: 100,
317
- start: options.width * 100 / containerWidth
318
- },
319
- px: {
320
- min: minWidth,
321
- max: maxWidth,
322
- start: +options.width
323
- }
283
+ current: {
284
+ width: options.width,
285
+ height: options.height
286
+ }
287
+ },
288
+ '%': {
289
+ natural: {
290
+ width: 100,
291
+ height: null
324
292
  },
325
- currentUnit: '%'
326
- };
327
- },
328
-
329
- /**
330
- * Toggle width/height synchronization
331
- *
332
- * @param $elt
333
- * @returns {*}
334
- * @private
335
- */
336
- _initSyncBtn: function ($elt) {
337
- var options = $elt.data(dataNs),
338
- $mediaSizer = $elt.find('.media-sizer'),
339
- self = this,
340
- $syncBtn = $elt.find('.media-sizer-sync');
341
-
342
- if (!options.showSync) {
343
- $syncBtn.hide();
344
- $mediaSizer.addClass('media-sizer-sync-off');
345
- } // this stays intact even if hidden in case it will be
346
- // displayed from somewhere else
347
-
348
-
349
- $syncBtn.on('click', function () {
350
- $mediaSizer.toggleClass('media-sizer-synced');
351
- options.syncDimensions = $mediaSizer.hasClass('media-sizer-synced');
352
-
353
- if (options.syncDimensions) {
354
- self._sync($elt, options.$fields.px.width, 'blur');
293
+ current: {
294
+ width: options.width * 100 / containerWidth,
295
+ height: null // height does not work on % - this is just in case you have to loop or something
296
+
355
297
  }
356
- });
357
- return $syncBtn;
358
- },
359
-
360
- /**
361
- * Button to reset the size to its original values
362
- *
363
- * @param $elt
364
- * @returns {*}
365
- * @private
366
- */
367
- _initResetBtn: function ($elt) {
368
- var options = $elt.data(dataNs),
369
- $resetBtn = $elt.find('.media-sizer-reset');
370
-
371
- if (!options.showReset) {
372
- $elt.find('.media-sizer').addClass('media-sizer-reset-off');
373
- } // this stays intact even if hidden in case it will be
374
- // displayed from somewhere else
375
-
376
-
377
- $resetBtn.on('click', function () {
378
- // this will take care of all other size changes
379
- options.$fields.px.width.val(options.originalSizeProps.px.current.width).trigger('sliderchange');
380
- });
381
- return $resetBtn;
382
- },
383
-
384
- /**
385
- * Blocks are the two different parts of the form (either width|height or size)
386
- *
387
- * @param $elt
388
- * @returns {{}}
389
- * @private
390
- */
391
- _initBlocks: function ($elt) {
392
- var options = $elt.data(dataNs),
393
- _blocks = {},
394
- $responsiveToggleField = $elt.find('.media-mode-switch'),
395
- self = this,
396
- _checkMode = function () {
397
- if ($responsiveToggleField.is(':checked')) {
398
- _blocks.px.hide();
399
-
400
- _blocks['%'].show();
401
-
402
- options.sizeProps.currentUnit = '%';
403
-
404
- if (options.$fields && options.$fields['%'].width.val() > options.sizeProps.sliders['%'].max) {
405
- options.$fields['%'].width.val(options.sizeProps.sliders['%'].max);
406
-
407
- self._sync($elt, options.$fields['%'].width, 'blur');
408
- }
409
- } else {
410
- _blocks['%'].hide();
411
-
412
- _blocks.px.show();
413
-
414
- options.sizeProps.currentUnit = 'px';
298
+ },
299
+ ratio: {
300
+ natural: naturalWidth / naturalHeight,
301
+ current: options.width / options.height
302
+ },
303
+ containerWidth: containerWidth,
304
+ sliders: {
305
+ '%': {
306
+ min: minWidth * 100 / maxWidth,
307
+ max: 100,
308
+ start: options.width * 100 / containerWidth
309
+ },
310
+ px: {
311
+ min: minWidth,
312
+ max: maxWidth,
313
+ start: +options.width
415
314
  }
416
- };
315
+ },
316
+ currentUnit: '%'
317
+ };
318
+ },
417
319
 
418
- if (!options.showResponsiveToggle) {
419
- $elt.find('.media-sizer').addClass('media-sizer-responsivetoggle-off');
320
+ /**
321
+ * Toggle width/height synchronization
322
+ *
323
+ * @param $elt
324
+ * @returns {*}
325
+ * @private
326
+ */
327
+ _initSyncBtn: function _initSyncBtn($elt) {
328
+ var options = $elt.data(dataNs),
329
+ $mediaSizer = $elt.find('.media-sizer'),
330
+ self = this,
331
+ $syncBtn = $elt.find('.media-sizer-sync');
332
+
333
+ if (!options.showSync) {
334
+ $syncBtn.hide();
335
+ $mediaSizer.addClass('media-sizer-sync-off');
336
+ } // this stays intact even if hidden in case it will be
337
+ // displayed from somewhere else
338
+
339
+
340
+ $syncBtn.on('click', function () {
341
+ $mediaSizer.toggleClass('media-sizer-synced');
342
+ options.syncDimensions = $mediaSizer.hasClass('media-sizer-synced');
343
+
344
+ if (options.syncDimensions) {
345
+ self._sync($elt, options.$fields.px.width, 'blur');
420
346
  }
347
+ });
348
+ return $syncBtn;
349
+ },
421
350
 
422
- _(['px', '%']).forEach(function (unit) {
423
- _blocks[unit] = $elt.find('.media-sizer-' + (unit === 'px' ? 'pixel' : 'percent'));
351
+ /**
352
+ * Button to reset the size to its original values
353
+ *
354
+ * @param $elt
355
+ * @returns {*}
356
+ * @private
357
+ */
358
+ _initResetBtn: function _initResetBtn($elt) {
359
+ var options = $elt.data(dataNs),
360
+ $resetBtn = $elt.find('.media-sizer-reset');
424
361
 
425
- _blocks[unit].prop('unit', unit);
362
+ if (!options.showReset) {
363
+ $elt.find('.media-sizer').addClass('media-sizer-reset-off');
364
+ } // this stays intact even if hidden in case it will be
365
+ // displayed from somewhere else
426
366
 
427
- _blocks[unit].find('input').data('unit', unit).after($$1('<span>', {
428
- class: 'unit-indicator',
429
- text: unit
430
- }));
431
- });
432
367
 
433
- $responsiveToggleField.on('click', function () {
434
- _checkMode();
368
+ $resetBtn.on('click', function () {
369
+ // this will take care of all other size changes
370
+ options.$fields.px.width.val(options.originalSizeProps.px.current.width).trigger('sliderchange');
371
+ });
372
+ return $resetBtn;
373
+ },
435
374
 
436
- $elt.trigger('responsiveswitch.' + ns, [$responsiveToggleField.is(':checked')]);
437
- $elt.trigger('sizechange.' + ns, self._publicArgs($elt, options));
438
- }); //initialize it properly
375
+ /**
376
+ * Blocks are the two different parts of the form (either width|height or size)
377
+ *
378
+ * @param $elt
379
+ * @returns {{}}
380
+ * @private
381
+ */
382
+ _initBlocks: function _initBlocks($elt) {
383
+ var options = $elt.data(dataNs),
384
+ _blocks = {},
385
+ $responsiveToggleField = $elt.find('.media-mode-switch'),
386
+ self = this,
387
+ _checkMode = function _checkMode() {
388
+ if ($responsiveToggleField.is(':checked')) {
389
+ _blocks.px.hide();
439
390
 
440
- _checkMode();
391
+ _blocks['%'].show();
441
392
 
442
- return _blocks;
443
- },
444
-
445
- /**
446
- * Initialize the two sliders, one based on pixels the other on percentage
447
- *
448
- * @param $elt
449
- * @returns {{}}
450
- * @private
451
- */
452
- _initSliders: function ($elt) {
453
- var options = $elt.data(dataNs),
454
- _sliders = {};
455
-
456
- _(options.$blocks).forOwn(function ($block, unit) {
457
- _sliders[unit] = $block.find('.media-sizer-slider');
458
-
459
- _sliders[unit].prop('unit', unit);
460
-
461
- _sliders[unit].noUiSlider({
462
- start: options.sizeProps.sliders[unit].start,
463
- range: {
464
- min: options.sizeProps.sliders[unit].min,
465
- max: options.sizeProps.sliders[unit].max
466
- }
467
- }).on('slide', function () {
468
- var $slider = $$1(this),
469
- _unit = $slider.prop('unit');
393
+ options.sizeProps.currentUnit = '%';
470
394
 
471
- options.$fields[_unit].width.val(_round($slider.val(), 0)).trigger('sliderchange');
472
- });
473
- });
395
+ if (options.$fields && options.$fields['%'].width.val() > options.sizeProps.sliders['%'].max) {
396
+ options.$fields['%'].width.val(options.sizeProps.sliders['%'].max);
474
397
 
475
- return _sliders;
476
- },
477
-
478
- /**
479
- * Synchronize all parameters
480
- *
481
- * @param $elt
482
- * @param $field
483
- * @param eventType
484
- * @private
485
- */
486
- _sync: function ($elt, $field, eventType) {
487
- var self = this;
488
- var options = $elt.data(dataNs),
489
- unit = $field.prop('unit'),
490
- dimension = $field.prop('dimension'),
491
- value = parseFloat($field.val()),
492
- heightValue,
493
- ratio,
494
- otherBlockUnit,
495
- otherBlockWidthValue,
496
- otherBlockHeightValue,
497
- currentValues;
498
- eventType = eventType === 'sliderchange' ? 'sliderEvent' : 'fieldEvent'; // invalid entries
499
-
500
- if (isNaN(value)) {
501
- return;
502
- } // Re-calculate current ratio
503
- // change scenario: someone has typed height and width in pixels while syncing was off
504
- // whether current or natural ratio eventually will be used depends on options.denyCustomRatio
398
+ self._sync($elt, options.$fields['%'].width, 'blur');
399
+ }
400
+ } else {
401
+ _blocks['%'].hide();
505
402
 
403
+ _blocks.px.show();
506
404
 
507
- if (options.sizeProps.px.current.width > 0 && options.sizeProps.px.current.height > 0) {
508
- options.sizeProps.ratio.current = options.sizeProps.px.current.width / options.sizeProps.px.current.height;
405
+ options.sizeProps.currentUnit = 'px';
509
406
  }
407
+ };
510
408
 
511
- ratio = options.denyCustomRatio ? options.sizeProps.ratio.natural : options.sizeProps.ratio.current;
512
- ratio = ratio ? ratio : 1; // There is only one scenario where dimension != width: manual input of the height in px
513
- // this is treated here separately because then we just need to deal with widths below
409
+ if (!options.showResponsiveToggle) {
410
+ $elt.find('.media-sizer').addClass('media-sizer-responsivetoggle-off');
411
+ }
514
412
 
515
- if (dimension === 'height' && unit === 'px') {
516
- options.sizeProps.px.current.height = value;
413
+ _(['px', '%']).forEach(function (unit) {
414
+ _blocks[unit] = $elt.find('.media-sizer-' + (unit === 'px' ? 'pixel' : 'percent'));
517
415
 
518
- if (options.syncDimensions) {
519
- options.sizeProps.px.current.width = value * ratio;
520
- options.sizeProps.ratio.current = options.sizeProps.px.current.width / options.sizeProps.px.current.height;
521
- options.$fields.px.width.val(_round(options.sizeProps.px.current.width, 0)); // now all values can be set to the width since width entry is now the only scenario
416
+ _blocks[unit].prop('unit', unit);
522
417
 
523
- value = parseFloat(options.$fields.px.width.val());
524
- } else {
525
- options.sizeProps['%'].current.height = null; // update medium
418
+ _blocks[unit].find('input').data('unit', unit).after($$1('<span>', {
419
+ class: 'unit-indicator',
420
+ text: unit
421
+ }));
422
+ });
526
423
 
527
- if (options.applyToMedium) {
528
- currentValues = this._getValues($elt);
529
- options.target.attr('width', currentValues.width);
530
- options.target.attr('height', currentValues.height);
531
- }
424
+ $responsiveToggleField.on('click', function () {
425
+ _checkMode();
532
426
 
533
- $elt.trigger('sizechange.' + ns, this._publicArgs($elt, options));
534
- return;
427
+ $elt.trigger('responsiveswitch.' + ns, [$responsiveToggleField.is(':checked')]);
428
+ $elt.trigger('sizechange.' + ns, self._publicArgs($elt, options));
429
+ }); //initialize it properly
430
+
431
+ _checkMode();
432
+
433
+ return _blocks;
434
+ },
435
+
436
+ /**
437
+ * Initialize the two sliders, one based on pixels the other on percentage
438
+ *
439
+ * @param $elt
440
+ * @returns {{}}
441
+ * @private
442
+ */
443
+ _initSliders: function _initSliders($elt) {
444
+ var options = $elt.data(dataNs),
445
+ _sliders = {};
446
+
447
+ _(options.$blocks).forOwn(function ($block, unit) {
448
+ _sliders[unit] = $block.find('.media-sizer-slider');
449
+
450
+ _sliders[unit].prop('unit', unit);
451
+
452
+ _sliders[unit].noUiSlider({
453
+ start: options.sizeProps.sliders[unit].start,
454
+ range: {
455
+ min: options.sizeProps.sliders[unit].min,
456
+ max: options.sizeProps.sliders[unit].max
535
457
  }
536
- } // *** as of here we can be sure that the dimension is 'width' *** //
537
- // remember that heightValue and otherUnit work _not_ on the same block
458
+ }).on('slide', function () {
459
+ var $slider = $$1(this),
460
+ _unit = $slider.prop('unit');
538
461
 
462
+ options.$fields[_unit].width.val(_round($slider.val(), 0)).trigger('sliderchange');
463
+ });
464
+ });
539
465
 
540
- if (unit === 'px') {
541
- otherBlockUnit = '%';
542
- otherBlockWidthValue = value * 100 / options.sizeProps.containerWidth;
543
- } else {
544
- otherBlockUnit = 'px';
545
- otherBlockWidthValue = value * options.sizeProps.containerWidth / 100;
546
- } // update the unit-side of the tree with the value
466
+ return _sliders;
467
+ },
468
+
469
+ /**
470
+ * Synchronize all parameters
471
+ *
472
+ * @param $elt
473
+ * @param $field
474
+ * @param eventType
475
+ * @private
476
+ */
477
+ _sync: function _sync($elt, $field, eventType) {
478
+ var self = this;
479
+ var options = $elt.data(dataNs),
480
+ unit = $field.prop('unit'),
481
+ dimension = $field.prop('dimension'),
482
+ value = parseFloat($field.val()),
483
+ heightValue,
484
+ ratio,
485
+ otherBlockUnit,
486
+ otherBlockWidthValue,
487
+ otherBlockHeightValue,
488
+ currentValues;
489
+ eventType = eventType === 'sliderchange' ? 'sliderEvent' : 'fieldEvent'; // invalid entries
490
+
491
+ if (isNaN(value)) {
492
+ return;
493
+ } // Re-calculate current ratio
494
+ // change scenario: someone has typed height and width in pixels while syncing was off
495
+ // whether current or natural ratio eventually will be used depends on options.denyCustomRatio
496
+
497
+
498
+ if (options.sizeProps.px.current.width > 0 && options.sizeProps.px.current.height > 0) {
499
+ options.sizeProps.ratio.current = options.sizeProps.px.current.width / options.sizeProps.px.current.height;
500
+ }
547
501
 
502
+ ratio = options.denyCustomRatio ? options.sizeProps.ratio.natural : options.sizeProps.ratio.current;
503
+ ratio = ratio ? ratio : 1; // There is only one scenario where dimension != width: manual input of the height in px
504
+ // this is treated here separately because then we just need to deal with widths below
548
505
 
549
- options.sizeProps[unit].current.width = value;
550
- options.sizeProps[otherBlockUnit].current.width = otherBlockWidthValue; // update the height fields of the same and of the other block
506
+ if (dimension === 'height' && unit === 'px') {
507
+ options.sizeProps.px.current.height = value;
551
508
 
552
509
  if (options.syncDimensions) {
553
- heightValue = value / ratio;
554
- otherBlockHeightValue = otherBlockWidthValue / ratio; //same block
510
+ options.sizeProps.px.current.width = value * ratio;
511
+ options.sizeProps.ratio.current = options.sizeProps.px.current.width / options.sizeProps.px.current.height;
512
+ options.$fields.px.width.val(_round(options.sizeProps.px.current.width, 0)); // now all values can be set to the width since width entry is now the only scenario
555
513
 
556
- options.sizeProps[unit].current.height = heightValue;
557
- options.$fields[unit].height.val(_round(heightValue, 0)); //other block
514
+ value = parseFloat(options.$fields.px.width.val());
515
+ } else {
516
+ options.sizeProps['%'].current.height = null; // update medium
517
+
518
+ if (options.applyToMedium) {
519
+ currentValues = this._getValues($elt);
520
+ options.target.attr('width', currentValues.width);
521
+ options.target.attr('height', currentValues.height);
522
+ }
558
523
 
559
- options.sizeProps[otherBlockUnit].current.height = otherBlockHeightValue;
560
- options.$fields[otherBlockUnit].height.val(_round(otherBlockHeightValue, 0));
524
+ $elt.trigger('sizechange.' + ns, this._publicArgs($elt, options));
525
+ return;
561
526
  }
562
- /* sliders */
563
- // update same slider value only when fn is triggered by typing
527
+ } // *** as of here we can be sure that the dimension is 'width' *** //
528
+ // remember that heightValue and otherUnit work _not_ on the same block
564
529
 
565
530
 
566
- if (eventType !== 'sliderEvent') {
567
- options.$sliders[unit].val(value);
568
- } // update other slider
531
+ if (unit === 'px') {
532
+ otherBlockUnit = '%';
533
+ otherBlockWidthValue = value * 100 / options.sizeProps.containerWidth;
534
+ } else {
535
+ otherBlockUnit = 'px';
536
+ otherBlockWidthValue = value * options.sizeProps.containerWidth / 100;
537
+ } // update the unit-side of the tree with the value
569
538
 
570
539
 
571
- options.$sliders[otherBlockUnit].val(otherBlockWidthValue); // update other width field
540
+ options.sizeProps[unit].current.width = value;
541
+ options.sizeProps[otherBlockUnit].current.width = otherBlockWidthValue; // update the height fields of the same and of the other block
572
542
 
573
- options.$fields[otherBlockUnit].width.val(_round(otherBlockWidthValue, 0)); // reset percent height to null
543
+ if (options.syncDimensions) {
544
+ heightValue = value / ratio;
545
+ otherBlockHeightValue = otherBlockWidthValue / ratio; //same block
574
546
 
575
- options.sizeProps['%'].current.height = null; // update medium
547
+ options.sizeProps[unit].current.height = heightValue;
548
+ options.$fields[unit].height.val(_round(heightValue, 0)); //other block
576
549
 
577
- if (options.applyToMedium) {
578
- currentValues = this._getValues($elt);
579
- options.target.attr('width', currentValues.width);
580
- options.target.attr('height', currentValues.height || 'auto');
581
- }
550
+ options.sizeProps[otherBlockUnit].current.height = otherBlockHeightValue;
551
+ options.$fields[otherBlockUnit].height.val(_round(otherBlockHeightValue, 0));
552
+ }
553
+ /* sliders */
554
+ // update same slider value only when fn is triggered by typing
582
555
 
583
- $elt.trigger('sizechange.' + ns, self._publicArgs($elt, options));
584
- },
585
-
586
- /**
587
- * Initialize the fields
588
- *
589
- * @param $elt
590
- * @returns {{}}
591
- * @private
592
- */
593
- _initFields: function ($elt) {
594
- var options = $elt.data(dataNs),
595
- dimensions = ['width', 'height'],
596
- field,
597
- _fields = {},
598
- self = this;
599
-
600
- _(options.$blocks).forOwn(function ($block, unit) {
601
- _fields[unit] = {};
602
- options.$blocks[unit].find('input').each(function () {
603
- _(dimensions).forEach(function (dim) {
604
- field = options.$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
605
-
606
- _fields[unit][dim] = field.length ? field : $$1('<input>');
607
-
608
- _fields[unit][dim].prop({
609
- unit: unit,
610
- dimension: dim
611
- });
612
-
613
- _fields[unit][dim].val(_round(options.sizeProps[unit].current[dim], 0));
614
-
615
- _fields[unit][dim].data({
616
- min: 0,
617
- max: options.sizeProps.sliders[unit].max
618
- });
619
-
620
- _fields[unit][dim].on('keydown', function (e) {
621
- var $field = $$1(this),
622
- c = e.keyCode,
623
- specChars = function () {
624
- var chars = [8, 37, 39, 46];
625
-
626
- if ($field.val().indexOf('.') === -1) {
627
- chars.push(190);
628
- chars.push(110);
629
- }
630
-
631
- return chars;
632
- }();
633
-
634
- return _.contains(specChars, c) || c >= 48 && c <= 57 || c >= 96 && c <= 105;
635
- });
636
-
637
- _fields[unit][dim].on('keyup blur sliderchange', function (e) {
638
- var $field = $$1(this),
639
- value = $field.val().replace(/,/g, '.');
640
- $field.val(value);
641
-
642
- if (value > $field.data('max')) {
643
- $field.val($field.data('max'));
644
- } else if (value < $field.data('min')) {
645
- $field.val($field.data('min'));
556
+
557
+ if (eventType !== 'sliderEvent') {
558
+ options.$sliders[unit].val(value);
559
+ } // update other slider
560
+
561
+
562
+ options.$sliders[otherBlockUnit].val(otherBlockWidthValue); // update other width field
563
+
564
+ options.$fields[otherBlockUnit].width.val(_round(otherBlockWidthValue, 0)); // reset percent height to null
565
+
566
+ options.sizeProps['%'].current.height = null; // update medium
567
+
568
+ if (options.applyToMedium) {
569
+ currentValues = this._getValues($elt);
570
+ options.target.attr('width', currentValues.width);
571
+ options.target.attr('height', currentValues.height || 'auto');
572
+ }
573
+
574
+ $elt.trigger('sizechange.' + ns, self._publicArgs($elt, options));
575
+ },
576
+
577
+ /**
578
+ * Initialize the fields
579
+ *
580
+ * @param $elt
581
+ * @returns {{}}
582
+ * @private
583
+ */
584
+ _initFields: function _initFields($elt) {
585
+ var options = $elt.data(dataNs),
586
+ dimensions = ['width', 'height'],
587
+ field,
588
+ _fields = {},
589
+ self = this;
590
+
591
+ _(options.$blocks).forOwn(function ($block, unit) {
592
+ _fields[unit] = {};
593
+ options.$blocks[unit].find('input').each(function () {
594
+ _(dimensions).forEach(function (dim) {
595
+ field = options.$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
596
+
597
+ _fields[unit][dim] = field.length ? field : $$1('<input>');
598
+
599
+ _fields[unit][dim].prop({
600
+ unit: unit,
601
+ dimension: dim
602
+ });
603
+
604
+ _fields[unit][dim].val(_round(options.sizeProps[unit].current[dim], 0));
605
+
606
+ _fields[unit][dim].data({
607
+ min: 0,
608
+ max: options.sizeProps.sliders[unit].max
609
+ });
610
+
611
+ _fields[unit][dim].on('keydown', function (e) {
612
+ var $field = $$1(this),
613
+ c = e.keyCode,
614
+ specChars = function () {
615
+ var chars = [8, 37, 39, 46];
616
+
617
+ if ($field.val().indexOf('.') === -1) {
618
+ chars.push(190);
619
+ chars.push(110);
646
620
  }
647
621
 
648
- self._sync($elt, $$1(this), e.type);
649
- });
622
+ return chars;
623
+ }();
624
+
625
+ return _.contains(specChars, c) || c >= 48 && c <= 57 || c >= 96 && c <= 105;
626
+ });
627
+
628
+ _fields[unit][dim].on('keyup blur sliderchange', function (e) {
629
+ var $field = $$1(this),
630
+ value = $field.val().replace(/,/g, '.');
631
+ $field.val(value);
632
+
633
+ if (value > $field.data('max')) {
634
+ $field.val($field.data('max'));
635
+ } else if (value < $field.data('min')) {
636
+ $field.val($field.data('min'));
637
+ }
638
+
639
+ self._sync($elt, $$1(this), e.type);
650
640
  });
651
641
  });
652
642
  });
643
+ });
653
644
 
654
- return _fields;
655
- },
656
-
657
- /**
658
- * Retrieve current size values in current unit
659
- *
660
- * @param $elt
661
- * @returns {{}}
662
- * @private
663
- */
664
- _getValues: function ($elt) {
665
- var options = $elt.data(dataNs),
666
- attr = {};
667
-
668
- _.forOwn(options.sizeProps[options.sizeProps.currentUnit].current, function (value, dimension) {
669
- if (_.isNull(value)) {
670
- value = '';
671
- } else {
672
- value = _round(value, 0).toString();
673
- }
645
+ return _fields;
646
+ },
674
647
 
675
- if (options.sizeProps.currentUnit === '%' && value !== '') {
676
- value += options.sizeProps.currentUnit;
677
- }
648
+ /**
649
+ * Retrieve current size values in current unit
650
+ *
651
+ * @param $elt
652
+ * @returns {{}}
653
+ * @private
654
+ */
655
+ _getValues: function _getValues($elt) {
656
+ var options = $elt.data(dataNs),
657
+ attr = {};
678
658
 
679
- attr[dimension] = value;
680
- });
659
+ _.forOwn(options.sizeProps[options.sizeProps.currentUnit].current, function (value, dimension) {
660
+ if (_.isNull(value)) {
661
+ value = '';
662
+ } else {
663
+ value = _round(value, 0).toString();
664
+ }
681
665
 
682
- return attr;
683
- },
684
-
685
- /**
686
- * Initialize the plugin.
687
- *
688
- * Called the jQuery way once registered by the Pluginifier.
689
- * @example $('selector').mediaSizer({target : $('target') });
690
- * @public
691
- *
692
- * @constructor
693
- * @returns {*}
694
- */
695
- init: function (options) {
696
- //get options using default
697
- options = $$1.extend(true, {}, defaults, options);
698
- return this.each(function () {
699
- var $elt = $$1(this);
700
- options.hasTarget = options.target && options.target.length; // compatibility layer naturalWidth|Height vs. naturalHeight
701
- // internally width/height are used
702
-
703
- options.width = options.width || options.naturalWidth || options.maxWidth || defaults.size;
704
- options.height = options.height || options.naturalHeight || defaults.size;
705
- options.naturalWidth = options.naturalWidth || options.width || defaults.size;
706
- options.naturalHeight = options.naturalHeight || options.height || defaults.size;
707
- options.hasSize = _.isFinite(+options.width) && _.isFinite(+options.height); // incomplete or conflicting configurations
708
- // no target provided, also no width and/or no height
709
-
710
- if (!options.hasTarget && !options.hasSize) {
711
- throw new Error('MediaSizer::init() You must either set width and height or a target element');
712
- } // no target provided, but applyToMedium = true
713
- else if (!options.hasTarget && options.applyToMedium) {
714
- throw new Error('MediaSizer::init() options.applyToMedium can only be true if a target element is provided');
715
- } // target quietly takes precedence over width and height
716
- else if (options.hasTarget && options.hasSize) {
717
- delete options.width;
718
- delete options.height;
719
- options.hasSize = false;
720
- }
666
+ if (options.sizeProps.currentUnit === '%' && value !== '') {
667
+ value += options.sizeProps.currentUnit;
668
+ }
721
669
 
722
- if (!$elt.data(dataNs)) {
723
- $elt.html(tpl({
724
- responsive: typeof options.responsive !== 'undefined' ? !!options.responsive : true
725
- })); //add data to the element
726
-
727
- $elt.data(dataNs, options);
728
- options.sizeProps = MediaSizer._getSizeProps($elt);
729
- options.originalSizeProps = _.cloneDeep(options.sizeProps);
730
- options.syncDimensions = $elt.find('.media-sizer').hasClass('media-sizer-synced');
731
- options.$blocks = MediaSizer._initBlocks($elt);
732
- options.$fields = MediaSizer._initFields($elt);
733
- options.$sliders = MediaSizer._initSliders($elt);
734
- options.$syncBtn = MediaSizer._initSyncBtn($elt);
735
- options.$resetBtn = MediaSizer._initResetBtn($elt);
736
- /**
737
- * The plugin has been created
738
- * @event MediaSizer#create.toggler
739
- */
740
-
741
- $elt.trigger('create.' + ns, MediaSizer._publicArgs($elt, options));
742
- }
743
- });
744
- },
745
-
746
- /**
747
- * Destroy the plugin completely.
748
- * Called the jQuery way once registered by the Pluginifier.
749
- *
750
- * @example $('selector').toggler('destroy');
751
- * @public
752
- */
753
- destroy: function () {
754
- this.each(function () {
755
- var $elt = $$1(this);
670
+ attr[dimension] = value;
671
+ });
672
+
673
+ return attr;
674
+ },
675
+
676
+ /**
677
+ * Initialize the plugin.
678
+ *
679
+ * Called the jQuery way once registered by the Pluginifier.
680
+ * @example $('selector').mediaSizer({target : $('target') });
681
+ * @public
682
+ *
683
+ * @constructor
684
+ * @returns {*}
685
+ */
686
+ init: function init(options) {
687
+ //get options using default
688
+ options = $$1.extend(true, {}, defaults, options);
689
+ return this.each(function () {
690
+ var $elt = $$1(this);
691
+ options.hasTarget = options.target && options.target.length; // compatibility layer naturalWidth|Height vs. naturalHeight
692
+ // internally width/height are used
693
+
694
+ options.width = options.width || options.naturalWidth || options.maxWidth || defaults.size;
695
+ options.height = options.height || options.naturalHeight || defaults.size;
696
+ options.naturalWidth = options.naturalWidth || options.width || defaults.size;
697
+ options.naturalHeight = options.naturalHeight || options.height || defaults.size;
698
+ options.hasSize = _.isFinite(+options.width) && _.isFinite(+options.height); // incomplete or conflicting configurations
699
+ // no target provided, also no width and/or no height
700
+
701
+ if (!options.hasTarget && !options.hasSize) {
702
+ throw new Error('MediaSizer::init() You must either set width and height or a target element');
703
+ } // no target provided, but applyToMedium = true
704
+ else if (!options.hasTarget && options.applyToMedium) {
705
+ throw new Error('MediaSizer::init() options.applyToMedium can only be true if a target element is provided');
706
+ } // target quietly takes precedence over width and height
707
+ else if (options.hasTarget && options.hasSize) {
708
+ delete options.width;
709
+ delete options.height;
710
+ options.hasSize = false;
711
+ }
712
+
713
+ if (!$elt.data(dataNs)) {
714
+ $elt.html(tpl({
715
+ responsive: typeof options.responsive !== 'undefined' ? !!options.responsive : true
716
+ })); //add data to the element
717
+
718
+ $elt.data(dataNs, options);
719
+ options.sizeProps = MediaSizer._getSizeProps($elt);
720
+ options.originalSizeProps = _.cloneDeep(options.sizeProps);
721
+ options.syncDimensions = $elt.find('.media-sizer').hasClass('media-sizer-synced');
722
+ options.$blocks = MediaSizer._initBlocks($elt);
723
+ options.$fields = MediaSizer._initFields($elt);
724
+ options.$sliders = MediaSizer._initSliders($elt);
725
+ options.$syncBtn = MediaSizer._initSyncBtn($elt);
726
+ options.$resetBtn = MediaSizer._initResetBtn($elt);
756
727
  /**
757
- * The plugin have been destroyed.
758
- * @event MediaSizer#destroy.toggler
728
+ * The plugin has been created
729
+ * @event MediaSizer#create.toggler
759
730
  */
760
731
 
761
- $elt.trigger('destroy.' + ns);
762
- });
763
- }
764
- }; //Register the toggler to behave as a jQuery plugin.
732
+ $elt.trigger('create.' + ns, MediaSizer._publicArgs($elt, options));
733
+ }
734
+ });
735
+ },
736
+
737
+ /**
738
+ * Destroy the plugin completely.
739
+ * Called the jQuery way once registered by the Pluginifier.
740
+ *
741
+ * @example $('selector').toggler('destroy');
742
+ * @public
743
+ */
744
+ destroy: function destroy() {
745
+ this.each(function () {
746
+ var $elt = $$1(this);
747
+ /**
748
+ * The plugin have been destroyed.
749
+ * @event MediaSizer#destroy.toggler
750
+ */
751
+
752
+ $elt.trigger('destroy.' + ns);
753
+ });
754
+ }
755
+ }; //Register the toggler to behave as a jQuery plugin.
765
756
 
766
- Pluginifier.register(ns, MediaSizer);
757
+ Pluginifier.register(ns, MediaSizer);
767
758
 
768
759
  });