@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.
- package/dist/actionbar.js +386 -395
- package/dist/adder.js +21 -19
- package/dist/animable/absorbable/absorbable.js +204 -213
- package/dist/animable/absorbable/css/absorb.css +1 -0
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +168 -177
- package/dist/autocomplete/css/autocomplete.css +1 -0
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +68 -66
- package/dist/badge/badge.js +188 -197
- package/dist/badge/css/badge.css +1 -0
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs.js +275 -284
- package/dist/btngrouper.js +5 -5
- package/dist/bulkActionPopup.js +490 -495
- package/dist/button.js +283 -291
- package/dist/cascadingComboBox.js +249 -258
- package/dist/ckeditor/ckConfigurator.js +26 -19
- package/dist/ckeditor/dtdHandler.js +11 -9
- package/dist/class/selector.js +441 -450
- package/dist/component/resizable.js +1 -1
- package/dist/component/windowed.js +285 -294
- package/dist/component.js +419 -428
- package/dist/contextualPopup.js +417 -426
- package/dist/dashboard.js +300 -309
- package/dist/datalist.js +753 -762
- package/dist/datatable/filterStrategy/multiple.js +1 -1
- package/dist/datatable/filterStrategy/single.js +1 -1
- package/dist/datatable.js +1527 -1550
- package/dist/dateRange/dateRange.js +393 -402
- package/dist/datetime/picker.js +665 -672
- package/dist/deleter.js +368 -377
- package/dist/destination/selector.js +286 -295
- package/dist/dialog/alert.js +3 -3
- package/dist/dialog/confirm.js +1 -1
- package/dist/dialog/confirmDelete.js +216 -225
- package/dist/dialog.js +650 -654
- package/dist/disabler.js +8 -8
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
- package/dist/documentViewer/providers/pdfViewer.js +184 -193
- package/dist/documentViewer.js +292 -301
- package/dist/dropdown.js +383 -392
- package/dist/durationer.js +5 -5
- package/dist/dynamicComponent.js +597 -598
- package/dist/feedback.js +356 -362
- package/dist/figure/FigureStateActive.js +117 -108
- package/dist/filesender.js +2 -2
- package/dist/filter.js +230 -239
- package/dist/form/dropdownForm.js +355 -357
- package/dist/form/form.js +919 -690
- package/dist/form/simpleForm.js +1 -1
- package/dist/form/validator/renderer.js +233 -235
- package/dist/form/validator/validator.js +257 -189
- package/dist/form/widget/definitions.js +1 -1
- package/dist/form/widget/providers/checkBox.js +254 -259
- package/dist/form/widget/providers/comboBox.js +187 -192
- package/dist/form/widget/providers/default.js +8 -9
- package/dist/form/widget/providers/hidden.js +170 -179
- package/dist/form/widget/providers/hiddenBox.js +262 -267
- package/dist/form/widget/providers/radioBox.js +216 -225
- package/dist/form/widget/providers/textArea.js +187 -196
- package/dist/form/widget/providers/textBox.js +2 -3
- package/dist/form/widget/widget.js +473 -475
- package/dist/formValidator/formValidator.js +1 -1
- package/dist/formValidator/highlighters/message.js +1 -1
- package/dist/generis/form/form.js +314 -323
- package/dist/generis/validator/validator.js +209 -218
- package/dist/generis/widget/checkBox/checkBox.js +218 -227
- package/dist/generis/widget/comboBox/comboBox.js +179 -188
- package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
- package/dist/generis/widget/textBox/textBox.js +169 -178
- package/dist/generis/widget/widget.js +246 -255
- package/dist/groupedComboBox.js +222 -231
- package/dist/groupvalidator.js +2 -2
- package/dist/highlighter.js +967 -958
- package/dist/image/ImgStateActive/helper.js +7 -5
- package/dist/image/ImgStateActive/initHelper.js +49 -43
- package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
- package/dist/image/ImgStateActive/mediaSizer.js +14 -12
- package/dist/image/ImgStateActive.js +72 -70
- package/dist/incrementer.js +6 -6
- package/dist/inplacer.js +6 -6
- package/dist/itemButtonList/css/item-button-list.css +1 -0
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +439 -435
- package/dist/keyNavigation/navigableDomElement.js +51 -38
- package/dist/keyNavigation/navigator.js +85 -70
- package/dist/listbox.js +460 -469
- package/dist/liststyler.js +8 -8
- package/dist/loadingButton/loadingButton.js +209 -218
- package/dist/lock.js +476 -485
- package/dist/login/login.js +475 -484
- package/dist/maths/calculator/basicCalculator.js +235 -244
- package/dist/maths/calculator/calculatorComponent.js +3 -3
- package/dist/maths/calculator/core/board.js +772 -781
- package/dist/maths/calculator/core/expression.js +476 -485
- package/dist/maths/calculator/core/labels.js +228 -237
- package/dist/maths/calculator/core/tokenizer.js +1 -1
- package/dist/maths/calculator/core/tokens.js +163 -170
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
- package/dist/maths/calculator/scientificCalculator.js +327 -336
- package/dist/mediaEditor/mediaEditorComponent.js +238 -245
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
- package/dist/mediaplayer/players/html5.js +666 -675
- package/dist/mediaplayer/players/youtube.js +419 -424
- package/dist/mediaplayer/support.js +11 -10
- package/dist/mediaplayer/utils/reminder.js +14 -13
- package/dist/mediaplayer/utils/timeObserver.js +10 -11
- package/dist/mediaplayer/youtubeManager.js +164 -145
- package/dist/mediaplayer.js +1565 -1520
- package/dist/mediasizer.js +669 -678
- package/dist/modal.js +10 -17
- package/dist/pageSizeSelector.js +219 -228
- package/dist/pagination/providers/pages.js +280 -289
- package/dist/pagination/providers/simple.js +192 -201
- package/dist/previewer.js +30 -30
- package/dist/progressbar.js +4 -4
- package/dist/report.js +347 -356
- package/dist/resource/filters.js +271 -280
- package/dist/resource/list.js +1264 -1273
- package/dist/resource/selector.js +865 -874
- package/dist/resource/tree.js +1483 -1492
- package/dist/resourcemgr/fileBrowser.js +564 -569
- package/dist/resourcemgr/filePreview.js +16 -16
- package/dist/resourcemgr/fileSelector.js +515 -524
- package/dist/resourcemgr/util/updatePermissions.js +2 -2
- package/dist/resourcemgr.js +306 -315
- package/dist/searchModal/advancedSearch.js +796 -767
- package/dist/searchModal.js +114 -91
- package/dist/switch/switch.js +298 -307
- package/dist/tabs.js +598 -575
- package/dist/taskQueue/status.js +312 -321
- package/dist/taskQueue/table.js +375 -384
- package/dist/taskQueue/taskQueueModel.js +488 -472
- package/dist/taskQueueButton/taskable.js +264 -273
- package/dist/taskQueueButton/treeButton.js +189 -198
- package/dist/themeLoader.js +24 -23
- package/dist/themes.js +1 -1
- package/dist/toggler.js +3 -3
- package/dist/tooltip.js +295 -304
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup.js +311 -320
- package/dist/uploader.js +687 -696
- package/dist/validator/Report.js +1 -1
- package/dist/validator/Validator.js +3 -3
- package/dist/validator/validators.js +9 -9
- package/dist/validator.js +240 -230
- package/dist/waitForMedia.js +1 -1
- package/package.json +3 -3
- package/src/animable/absorbable/css/absorb.css +1 -0
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css +1 -0
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/badge/css/badge.css +1 -0
- package/src/badge/css/badge.css.map +1 -1
- package/src/ckeditor/ckConfigurator.js +4 -0
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/.DS_Store +0 -0
- package/src/css/basic.css +0 -7826
- package/src/css/basic.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
- package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
- package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
- package/src/scss/.DS_Store +0 -0
- package/src/scss/basic.scss +0 -16
- package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
- package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
- package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
- package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
- package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
- package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
- package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
- package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
- package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
- package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
- package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
- package/src/scss/font/tao/tao.eot +0 -0
- package/src/scss/font/tao/tao.svg +0 -235
- package/src/scss/font/tao/tao.ttf +0 -0
- package/src/scss/font/tao/tao.woff +0 -0
- package/src/scss/inc/_base.scss +0 -496
- package/src/scss/inc/_bootstrap.scss +0 -6
- package/src/scss/inc/_buttons.scss +0 -114
- package/src/scss/inc/_colors.scss +0 -88
- package/src/scss/inc/_feedback.scss +0 -150
- package/src/scss/inc/_flex-grid.scss +0 -15
- package/src/scss/inc/_fonts.scss +0 -4
- package/src/scss/inc/_forms.scss +0 -827
- package/src/scss/inc/_functions.scss +0 -283
- package/src/scss/inc/_grid.scss +0 -66
- package/src/scss/inc/_jquery.nouislider.scss +0 -254
- package/src/scss/inc/_normalize.scss +0 -528
- package/src/scss/inc/_report.scss +0 -68
- package/src/scss/inc/_secondary-properties.scss +0 -89
- package/src/scss/inc/_select2.scss +0 -634
- package/src/scss/inc/_toolbars.scss +0 -155
- package/src/scss/inc/_tooltip.scss +0 -312
- package/src/scss/inc/_variables.scss +0 -21
- package/src/scss/inc/base/_highlight.scss +0 -5
- package/src/scss/inc/base/_list-style.scss +0 -59
- package/src/scss/inc/base/_svg.scss +0 -3
- package/src/scss/inc/base/_table.scss +0 -63
- package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
- package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
- package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
- 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
56
|
-
var
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* @
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
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
|
-
*
|
|
261
|
-
* @
|
|
262
|
-
* @
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Current component
|
|
316
|
+
*/
|
|
314
317
|
|
|
315
318
|
|
|
316
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
351
|
-
|
|
336
|
+
initialConfig = calculateCurrentSizes(initialConfig);
|
|
337
|
+
mediaDimensionComponent.update(); // restore current mode
|
|
352
338
|
|
|
353
|
-
|
|
354
|
-
},
|
|
339
|
+
initialConfig.syncDimensions = syncDim; // trigger event
|
|
355
340
|
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
377
|
-
if (typeof val !== 'string') {
|
|
378
|
-
val = `${val}`;
|
|
379
|
-
}
|
|
354
|
+
$fields['%'].width.val(Math.round(initialConfig.sizeProps['%'].current.width)); // px inputs
|
|
380
355
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
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
|
-
|
|
404
|
-
} else {
|
|
405
|
-
initialConfig.responsive = false;
|
|
390
|
+
_blocks.px.hide();
|
|
406
391
|
|
|
407
|
-
|
|
392
|
+
_blocks['%'].show();
|
|
408
393
|
|
|
409
|
-
|
|
394
|
+
initialConfig.sizeProps.currentUtil = '%';
|
|
395
|
+
} else {
|
|
396
|
+
initialConfig.responsive = false;
|
|
410
397
|
|
|
411
|
-
|
|
412
|
-
}
|
|
398
|
+
_blocks['%'].hide();
|
|
413
399
|
|
|
414
|
-
|
|
415
|
-
if ($fields['%'].width.val() > $slider.max) {
|
|
416
|
-
$fields['%'].width.val($slider.max);
|
|
417
|
-
}
|
|
400
|
+
_blocks.px.show();
|
|
418
401
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
-
|
|
428
|
-
|
|
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
|
-
|
|
432
|
-
|
|
418
|
+
if (!initialConfig.showResponsiveToggle) {
|
|
419
|
+
$elt.addClass('media-sizer-responsivetoggle-off');
|
|
420
|
+
}
|
|
433
421
|
|
|
434
|
-
|
|
422
|
+
_(['px', '%']).forEach(function (unit) {
|
|
423
|
+
_blocks[unit] = $elt.find(".media-sizer-".concat(unit === 'px' ? 'pixel' : 'percent'));
|
|
435
424
|
|
|
436
|
-
|
|
437
|
-
});
|
|
425
|
+
_blocks[unit].prop('unit', unit);
|
|
438
426
|
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
-
|
|
484
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|
-
|
|
498
|
+
var initFields = function initFields() {
|
|
499
|
+
var dimensions = ['width', 'height'];
|
|
500
|
+
var field;
|
|
501
|
+
var _fields = {};
|
|
519
502
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
509
|
+
_fields[unit][dim] = field.length ? field : $$1('<input>');
|
|
526
510
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const chars = [8, 37, 39, 46];
|
|
511
|
+
_fields[unit][dim].prop({
|
|
512
|
+
unit: unit,
|
|
513
|
+
dimension: dim
|
|
514
|
+
});
|
|
532
515
|
|
|
533
|
-
|
|
534
|
-
chars.push(190);
|
|
535
|
-
chars.push(110);
|
|
536
|
-
}
|
|
516
|
+
_fields[unit][dim].val(initialConfig.sizeProps[unit].current[dim]);
|
|
537
517
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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 (
|
|
543
|
-
|
|
524
|
+
if ($field.val().indexOf('.') === -1) {
|
|
525
|
+
chars.push(190);
|
|
526
|
+
chars.push(110);
|
|
544
527
|
}
|
|
545
528
|
|
|
546
|
-
return
|
|
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
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
533
|
+
if (!allowed) {
|
|
534
|
+
e.preventDefault();
|
|
535
|
+
}
|
|
559
536
|
|
|
560
|
-
|
|
561
|
-
|
|
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
|
-
|
|
569
|
-
|
|
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
|
-
|
|
567
|
+
height: value
|
|
572
568
|
};
|
|
573
569
|
} else {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
};
|
|
578
|
-
} else {
|
|
579
|
-
newDimensions = {
|
|
580
|
-
width: value
|
|
581
|
-
};
|
|
582
|
-
}
|
|
570
|
+
newDimensions = {
|
|
571
|
+
width: value
|
|
572
|
+
};
|
|
583
573
|
}
|
|
574
|
+
}
|
|
584
575
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
-
|
|
624
|
-
};
|
|
612
|
+
mediaDimensionComponent.update();
|
|
613
|
+
});
|
|
614
|
+
return slider;
|
|
615
|
+
};
|
|
625
616
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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
|
-
|
|
643
|
-
|
|
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
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
685
|
+
mediaDimensionComponent.update();
|
|
686
|
+
}).on('destroy', function () {
|
|
687
|
+
$template.remove();
|
|
688
|
+
});
|
|
698
689
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
690
|
+
_.defer(function () {
|
|
691
|
+
mediaDimensionComponent.init(config);
|
|
692
|
+
});
|
|
702
693
|
|
|
703
|
-
|
|
704
|
-
|
|
694
|
+
return mediaDimensionComponent;
|
|
695
|
+
}
|
|
705
696
|
|
|
706
|
-
|
|
697
|
+
return mediaDimensionFactory;
|
|
707
698
|
|
|
708
699
|
});
|