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