@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
package/dist/mediasizer.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
i: i
|
|
94
|
-
}));
|
|
64
|
+
if (keyValueGlue !== undefined) {
|
|
65
|
+
fragment += key + keyValueGlue;
|
|
95
66
|
}
|
|
96
67
|
|
|
97
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
228
|
+
* Creates object that contains all size related data of the medium (= image, video, etc.)
|
|
201
229
|
*
|
|
202
|
-
* @param
|
|
203
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
419
|
-
|
|
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
|
-
|
|
423
|
-
|
|
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
|
-
|
|
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
|
-
|
|
434
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
391
|
+
_blocks['%'].show();
|
|
441
392
|
|
|
442
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
512
|
-
|
|
513
|
-
|
|
409
|
+
if (!options.showResponsiveToggle) {
|
|
410
|
+
$elt.find('.media-sizer').addClass('media-sizer-responsivetoggle-off');
|
|
411
|
+
}
|
|
514
412
|
|
|
515
|
-
|
|
516
|
-
|
|
413
|
+
_(['px', '%']).forEach(function (unit) {
|
|
414
|
+
_blocks[unit] = $elt.find('.media-sizer-' + (unit === 'px' ? 'pixel' : 'percent'));
|
|
517
415
|
|
|
518
|
-
|
|
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
|
-
|
|
524
|
-
|
|
525
|
-
|
|
418
|
+
_blocks[unit].find('input').data('unit', unit).after($$1('<span>', {
|
|
419
|
+
class: 'unit-indicator',
|
|
420
|
+
text: unit
|
|
421
|
+
}));
|
|
422
|
+
});
|
|
526
423
|
|
|
527
|
-
|
|
528
|
-
|
|
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
|
-
|
|
534
|
-
|
|
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
|
-
}
|
|
537
|
-
|
|
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
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
-
|
|
550
|
-
options.sizeProps
|
|
506
|
+
if (dimension === 'height' && unit === 'px') {
|
|
507
|
+
options.sizeProps.px.current.height = value;
|
|
551
508
|
|
|
552
509
|
if (options.syncDimensions) {
|
|
553
|
-
|
|
554
|
-
|
|
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.
|
|
557
|
-
|
|
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
|
-
|
|
560
|
-
|
|
524
|
+
$elt.trigger('sizechange.' + ns, this._publicArgs($elt, options));
|
|
525
|
+
return;
|
|
561
526
|
}
|
|
562
|
-
|
|
563
|
-
|
|
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
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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
|
-
|
|
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
|
-
|
|
543
|
+
if (options.syncDimensions) {
|
|
544
|
+
heightValue = value / ratio;
|
|
545
|
+
otherBlockHeightValue = otherBlockWidthValue / ratio; //same block
|
|
574
546
|
|
|
575
|
-
options.sizeProps[
|
|
547
|
+
options.sizeProps[unit].current.height = heightValue;
|
|
548
|
+
options.$fields[unit].height.val(_round(heightValue, 0)); //other block
|
|
576
549
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
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
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
676
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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
|
|
758
|
-
* @event MediaSizer#
|
|
728
|
+
* The plugin has been created
|
|
729
|
+
* @event MediaSizer#create.toggler
|
|
759
730
|
*/
|
|
760
731
|
|
|
761
|
-
$elt.trigger('
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
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
|
-
|
|
757
|
+
Pluginifier.register(ns, MediaSizer);
|
|
767
758
|
|
|
768
759
|
});
|