vgapp 1.4.4 → 1.4.6
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/README.md +270 -270
- package/app/langs/en/buttons.json +17 -17
- package/app/langs/en/messages.json +36 -36
- package/app/langs/ru/buttons.json +17 -17
- package/app/langs/ru/messages.json +36 -36
- package/app/modules/vgalert/js/vgalert.js +266 -266
- package/app/modules/vgalert/scss/_variables.scss +16 -16
- package/app/modules/vgalert/scss/vgalert.scss +107 -107
- package/app/modules/vgcollapse/scss/_variables.scss +7 -7
- package/app/modules/vgcollapse/scss/vgcollapse.scss +5 -5
- package/app/modules/vgdropdown/scss/_variables.scss +14 -14
- package/app/modules/vgdropdown/scss/vgdropdown.scss +5 -5
- package/app/modules/vgdynamictable/index.js +4 -4
- package/app/modules/vgdynamictable/js/filters.js +21 -21
- package/app/modules/vgdynamictable/js/fixed.js +179 -179
- package/app/modules/vgdynamictable/js/options.js +3 -3
- package/app/modules/vgdynamictable/js/pagination.js +1 -1
- package/app/modules/vgdynamictable/js/search.js +12 -12
- package/app/modules/vgdynamictable/js/skeleton.js +27 -19
- package/app/modules/vgdynamictable/js/sortable.js +71 -71
- package/app/modules/vgdynamictable/js/summary-footer.js +28 -28
- package/app/modules/vgdynamictable/js/table-url-state.js +31 -31
- package/app/modules/vgdynamictable/js/utils/common.js +48 -48
- package/app/modules/vgdynamictable/js/vgdynamictable.js +79 -79
- package/app/modules/vgdynamictable/scss/_actions.scss +19 -19
- package/app/modules/vgdynamictable/scss/_pagination.scss +5 -5
- package/app/modules/vgdynamictable/scss/_skeleton.scss +11 -11
- package/app/modules/vgdynamictable/scss/_sortable.scss +28 -28
- package/app/modules/vgdynamictable/scss/_table.scss +7 -30
- package/app/modules/vgdynamictable/scss/_variables.scss +46 -46
- package/app/modules/vgdynamictable/scss/vgdynamictable.scss +28 -36
- package/app/modules/vgfilepreview/js/i18n.js +56 -56
- package/app/modules/vgfilepreview/js/renderers/image-modal.js +145 -145
- package/app/modules/vgfilepreview/js/renderers/image.js +92 -92
- package/app/modules/vgfilepreview/js/renderers/index.js +19 -19
- package/app/modules/vgfilepreview/js/renderers/office-modal.js +168 -168
- package/app/modules/vgfilepreview/js/renderers/office.js +79 -79
- package/app/modules/vgfilepreview/js/renderers/pdf-modal.js +260 -260
- package/app/modules/vgfilepreview/js/renderers/pdf.js +76 -76
- package/app/modules/vgfilepreview/js/renderers/playlist.js +71 -71
- package/app/modules/vgfilepreview/js/renderers/text-modal.js +343 -343
- package/app/modules/vgfilepreview/js/renderers/text.js +83 -83
- package/app/modules/vgfilepreview/js/renderers/video-modal.js +272 -272
- package/app/modules/vgfilepreview/js/renderers/video.js +80 -80
- package/app/modules/vgfilepreview/js/renderers/zip-modal.js +522 -522
- package/app/modules/vgfilepreview/js/renderers/zip.js +89 -89
- package/app/modules/vgfilepreview/js/vgfilepreview.js +7 -7
- package/app/modules/vgfilepreview/readme.md +68 -68
- package/app/modules/vgfilepreview/scss/_variables.scss +115 -115
- package/app/modules/vgfilepreview/scss/vgfilepreview.scss +463 -463
- package/app/modules/vgfiles/js/droppable.js +20 -9
- package/app/modules/vgfiles/js/render.js +153 -153
- package/app/modules/vgfiles/js/vgfiles.js +104 -104
- package/app/modules/vgfiles/readme.md +123 -123
- package/app/modules/vgfiles/scss/_mixins.scss +9 -9
- package/app/modules/vgfiles/scss/_variables.scss +41 -41
- package/app/modules/vgfiles/scss/vgfiles.scss +161 -161
- package/app/modules/vgformsender/js/hideshowpass.js +21 -16
- package/app/modules/vgformsender/js/vgformsender.js +4 -6
- package/app/modules/vgformsender/readme.md +1 -1
- package/app/modules/vgformsender/scss/_variables.scss +5 -5
- package/app/modules/vgformsender/scss/vgformsender.scss +42 -42
- package/app/modules/vglawcookie/js/vglawcookie.js +11 -8
- package/app/modules/vglawcookie/scss/_variables.scss +13 -13
- package/app/modules/vglawcookie/scss/vglawcookie.scss +5 -5
- package/app/modules/vgmodal/js/vgmodal.interaction.js +216 -216
- package/app/modules/vgmodal/js/vgmodal.js +355 -355
- package/app/modules/vgmodal/js/vgmodal.minimized.js +227 -227
- package/app/modules/vgmodal/scss/_variables.scss +17 -17
- package/app/modules/vgmodal/scss/vgmodal.scss +77 -77
- package/app/modules/vgnav/js/vgnav.js +180 -180
- package/app/modules/vgnav/scss/_breakpoints.scss +36 -36
- package/app/modules/vgnav/scss/_hamburger.scss +5 -5
- package/app/modules/vgnav/scss/_placement.scss +5 -5
- package/app/modules/vgnav/scss/_toggle.scss +5 -5
- package/app/modules/vgnav/scss/_variables.scss +26 -26
- package/app/modules/vgnav/scss/vgnav.scss +41 -41
- package/app/modules/vgnestable/README.md +39 -39
- package/app/modules/vgnestable/js/vgnestable.js +358 -358
- package/app/modules/vgnestable/scss/_variables.scss +35 -35
- package/app/modules/vgnestable/scss/vgnestable.scss +55 -55
- package/app/modules/vgrangeslider/js/skins.js +222 -222
- package/app/modules/vgrangeslider/js/vgrangeslider.js +704 -704
- package/app/modules/vgrangeslider/scss/_variables.scss +55 -55
- package/app/modules/vgrangeslider/scss/vgrangeslider.scss +239 -239
- package/app/modules/vgrollup/scss/_variables.scss +15 -15
- package/app/modules/vgrollup/scss/vgrollup.scss +6 -6
- package/app/modules/vgselect/js/vgselect.js +129 -129
- package/app/modules/vgselect/readme.md +11 -11
- package/app/modules/vgselect/scss/_variables.scss +50 -50
- package/app/modules/vgselect/scss/vgselect.scss +48 -48
- package/app/modules/vgsidebar/js/vgsidebar.js +79 -79
- package/app/modules/vgsidebar/scss/_variables.scss +10 -10
- package/app/modules/vgsidebar/scss/vgsidebar.scss +5 -5
- package/app/modules/vgtabs/scss/_variables.scss +23 -23
- package/app/modules/vgtabs/scss/vgtabs.scss +5 -5
- package/app/modules/vgtoast/scss/_variables.scss +13 -13
- package/app/modules/vgtoast/scss/vgtoast.scss +5 -5
- package/app/modules/vgtooltip/js/vgtooltip.js +107 -51
- package/app/modules/vgtooltip/scss/_variables.scss +10 -10
- package/app/modules/vgtooltip/scss/vgtooltip.scss +5 -5
- package/app/utils/js/components/audio-metadata.js +240 -240
- package/app/utils/js/components/backdrop.js +116 -116
- package/app/utils/js/components/file-icon.js +109 -109
- package/app/utils/js/components/file-preview.js +304 -304
- package/app/utils/js/components/sanitize.js +150 -150
- package/app/utils/js/components/video-metadata.js +140 -140
- package/app/utils/scss/_backdrop.scss +5 -5
- package/app/utils/scss/_theme-default.scss +12 -12
- package/app/utils/scss/_theme.scss +7 -7
- package/app/utils/scss/_tokens.scss +170 -170
- package/app/utils/scss/default.scss +9 -9
- package/app/utils/scss/functions.scss +21 -21
- package/app/utils/scss/index.scss +4 -4
- package/app/utils/scss/mixin.scss +16 -16
- package/app/utils/scss/variables.scss +105 -105
- package/app/vgapp.js +295 -295
- package/build/vgapp.css +1 -1
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +1 -1
- package/build/vgapp.js.map +1 -1
- package/index.scss +20 -20
- package/package.json +4 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
@use "../../../utils/scss" as vg;
|
|
2
|
-
|
|
3
|
-
$lawcookie-map: (
|
|
4
|
-
background-color: var(--vg-surface-bg, #{vg.$surface-bg}),
|
|
5
|
-
color: var(--vg-text-color, #{vg.$color}),
|
|
6
|
-
box-shadow: var(--vg-box-shadow, #{vg.$box-shadow}),
|
|
7
|
-
padding: 1rem,
|
|
8
|
-
border: vg.$border-width vg.$border-style var(--vg-border-color, #{vg.$border-color}),
|
|
9
|
-
border-radius: vg.$border-radius,
|
|
10
|
-
z-index: vg.$lawcookie-index,
|
|
11
|
-
transition: vg.$transition-base,
|
|
1
|
+
@use "../../../utils/scss" as vg;
|
|
2
|
+
|
|
3
|
+
$lawcookie-map: (
|
|
4
|
+
background-color: var(--vg-surface-bg, #{vg.$surface-bg}),
|
|
5
|
+
color: var(--vg-text-color, #{vg.$color}),
|
|
6
|
+
box-shadow: var(--vg-box-shadow, #{vg.$box-shadow}),
|
|
7
|
+
padding: 1rem,
|
|
8
|
+
border: vg.$border-width vg.$border-style var(--vg-border-color, #{vg.$border-color}),
|
|
9
|
+
border-radius: vg.$border-radius,
|
|
10
|
+
z-index: vg.$lawcookie-index,
|
|
11
|
+
transition: vg.$transition-base,
|
|
12
12
|
max-width: 50%,
|
|
13
13
|
padding-outer: 1rem,
|
|
14
14
|
font-size: 14px,
|
|
15
|
-
title-font-size: 16px
|
|
16
|
-
) !default;
|
|
15
|
+
title-font-size: 16px
|
|
16
|
+
) !default;
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
*--------------------------------------------------------------------------
|
|
7
7
|
**/
|
|
8
8
|
|
|
9
|
-
@forward "variables";
|
|
10
|
-
@use "../../../utils/scss" as vg;
|
|
11
|
-
@use "variables" as vars;
|
|
9
|
+
@forward "variables";
|
|
10
|
+
@use "../../../utils/scss" as vg;
|
|
11
|
+
@use "variables" as vars;
|
|
12
12
|
|
|
13
13
|
.vg-lawcookie {
|
|
14
|
-
@include vg.mix-vars('lawcookie', vars.$lawcookie-map);
|
|
14
|
+
@include vg.mix-vars('lawcookie', vars.$lawcookie-map);
|
|
15
15
|
position: fixed;
|
|
16
16
|
display: none;
|
|
17
17
|
padding: var(--vg-lawcookie-padding-outer);
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
font-size: var(--vg-lawcookie-title-font-size);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
import Selectors from "../../../utils/js/dom/selectors";
|
|
2
|
-
import VGModalDrag from "./vgmodal.drag";
|
|
3
|
-
import VGModalResize from "./vgmodal.resize";
|
|
4
|
-
|
|
5
|
-
const DEFAULTS = {
|
|
6
|
-
drag: {
|
|
7
|
-
enable: false,
|
|
8
|
-
selector: '.vg-modal-content',
|
|
9
|
-
threshold: 4,
|
|
10
|
-
resizeEdgeSize: 8,
|
|
11
|
-
debug: false,
|
|
12
|
-
},
|
|
13
|
-
resize: {
|
|
14
|
-
enable: false,
|
|
15
|
-
edgeSize: 8,
|
|
16
|
-
minWidth: 300,
|
|
17
|
-
minHeight: 160,
|
|
18
|
-
debug: false,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class VGModalInteraction {
|
|
23
|
-
constructor(modalElement, dialogElement, contentElement, getParams) {
|
|
24
|
-
this._modalElement = modalElement;
|
|
25
|
-
this._dialogElement = dialogElement;
|
|
26
|
-
this._contentElement = contentElement;
|
|
27
|
-
this._getParams = typeof getParams === 'function' ? getParams : () => ({});
|
|
28
|
-
this._dragHandler = new VGModalDrag(this._modalElement, this._dialogElement);
|
|
29
|
-
this._resizeHandler = new VGModalResize(this._modalElement, this._dialogElement);
|
|
30
|
-
this._config = this._resolveConfig();
|
|
31
|
-
|
|
32
|
-
this._bindHandlers();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
toggleHandlers() {
|
|
36
|
-
this._config = this._resolveConfig();
|
|
37
|
-
this._bindHandlers();
|
|
38
|
-
|
|
39
|
-
if (this._config.drag.enable) {
|
|
40
|
-
this._dragHandler.enable();
|
|
41
|
-
} else {
|
|
42
|
-
this._dragHandler.disable();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (this._config.resize.enable) {
|
|
46
|
-
this._resizeHandler.enable();
|
|
47
|
-
} else {
|
|
48
|
-
this._resizeHandler.disable();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
disableHandlers() {
|
|
53
|
-
this._dragHandler.disable();
|
|
54
|
-
this._resizeHandler.disable();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
syncBounds() {
|
|
58
|
-
if (this._config.resize.enable) {
|
|
59
|
-
this._resizeHandler.syncToViewport();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (this._config.drag.enable) {
|
|
63
|
-
this._dragHandler.syncPosition();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
saveState() {
|
|
68
|
-
const stateConfig = this._getStateConfig();
|
|
69
|
-
const storageKey = this._getStateStorageKey(stateConfig);
|
|
70
|
-
if (!stateConfig.enable || !storageKey || typeof window === 'undefined' || !window.localStorage) return;
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
window.localStorage.setItem(storageKey, JSON.stringify(this._captureState()));
|
|
74
|
-
} catch (error) {
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
restoreState() {
|
|
79
|
-
const stateConfig = this._getStateConfig();
|
|
80
|
-
const storageKey = this._getStateStorageKey(stateConfig);
|
|
81
|
-
if (!stateConfig.enable || !storageKey || typeof window === 'undefined' || !window.localStorage) return false;
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const rawState = window.localStorage.getItem(storageKey);
|
|
85
|
-
if (!rawState) return false;
|
|
86
|
-
|
|
87
|
-
const parsedState = JSON.parse(rawState);
|
|
88
|
-
this._applyState(parsedState);
|
|
89
|
-
return true;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
dispose() {
|
|
96
|
-
this.disableHandlers();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
_bindHandlers() {
|
|
100
|
-
this._dragHandler.setOptions(this._config.drag);
|
|
101
|
-
this._resizeHandler.setOptions(this._config.resize);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_resolveConfig() {
|
|
105
|
-
const params = this._getParams();
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
drag: this._normalizeInteractionParams(params.drag, DEFAULTS.drag),
|
|
109
|
-
resize: this._normalizeInteractionParams(params.resize, DEFAULTS.resize),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
_normalizeInteractionParams(paramsValue, defaults) {
|
|
114
|
-
if (typeof paramsValue === 'boolean') {
|
|
115
|
-
return {...defaults, enable: paramsValue};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (paramsValue && typeof paramsValue === 'object') {
|
|
119
|
-
const hasEnable = Object.prototype.hasOwnProperty.call(paramsValue, 'enable');
|
|
120
|
-
return {
|
|
121
|
-
...defaults,
|
|
122
|
-
...paramsValue,
|
|
123
|
-
enable: hasEnable ? Boolean(paramsValue.enable) : true,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {...defaults};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
_getStateConfig() {
|
|
131
|
-
const params = this._getParams();
|
|
132
|
-
return this._normalizeStateParams(params.state);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
_normalizeStateParams(paramsValue, defaults = { enable: true, key: '' }) {
|
|
136
|
-
if (typeof paramsValue === 'boolean') {
|
|
137
|
-
return {...defaults, enable: paramsValue};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (paramsValue && typeof paramsValue === 'object') {
|
|
141
|
-
const hasEnable = Object.prototype.hasOwnProperty.call(paramsValue, 'enable');
|
|
142
|
-
const key = typeof paramsValue.key === 'string' ? paramsValue.key.trim() : '';
|
|
143
|
-
return {
|
|
144
|
-
...defaults,
|
|
145
|
-
...paramsValue,
|
|
146
|
-
key,
|
|
147
|
-
enable: hasEnable ? Boolean(paramsValue.enable) : true,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {...defaults};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
_getStateStorageKey(stateConfig = this._getStateConfig()) {
|
|
155
|
-
if (!stateConfig.enable) return '';
|
|
156
|
-
|
|
157
|
-
if (typeof stateConfig.key === 'string' && stateConfig.key.trim()) {
|
|
158
|
-
return stateConfig.key.trim();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!this._modalElement || !this._modalElement.id) return '';
|
|
162
|
-
|
|
163
|
-
return `vg.modal.state:${window.location.pathname}:${this._modalElement.id}`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
_captureState() {
|
|
167
|
-
const dialogStyle = this._dialogElement ? this._dialogElement.style : null;
|
|
168
|
-
const contentElement = this._contentElement || Selectors.find('.vg-modal-content', this._dialogElement);
|
|
169
|
-
const contentStyle = contentElement ? contentElement.style : null;
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
dialog: dialogStyle ? {
|
|
173
|
-
position: dialogStyle.position,
|
|
174
|
-
margin: dialogStyle.margin,
|
|
175
|
-
left: dialogStyle.left,
|
|
176
|
-
top: dialogStyle.top,
|
|
177
|
-
width: dialogStyle.width,
|
|
178
|
-
height: dialogStyle.height,
|
|
179
|
-
transform: dialogStyle.transform,
|
|
180
|
-
maxWidth: dialogStyle.maxWidth,
|
|
181
|
-
maxHeight: dialogStyle.maxHeight,
|
|
182
|
-
minHeight: dialogStyle.minHeight,
|
|
183
|
-
overflow: dialogStyle.overflow,
|
|
184
|
-
pointerEvents: dialogStyle.pointerEvents,
|
|
185
|
-
transition: dialogStyle.transition,
|
|
186
|
-
willChange: dialogStyle.willChange,
|
|
187
|
-
} : {},
|
|
188
|
-
content: contentStyle ? {
|
|
189
|
-
height: contentStyle.height,
|
|
190
|
-
maxHeight: contentStyle.maxHeight,
|
|
191
|
-
overflow: contentStyle.overflow,
|
|
192
|
-
} : {},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
_applyState(state) {
|
|
197
|
-
if (!state || typeof state !== 'object') return;
|
|
198
|
-
|
|
199
|
-
const dialogState = state.dialog && typeof state.dialog === 'object' ? state.dialog : {};
|
|
200
|
-
const contentState = state.content && typeof state.content === 'object' ? state.content : {};
|
|
201
|
-
if (this._dialogElement) {
|
|
202
|
-
Object.keys(dialogState).forEach(propertyName => {
|
|
203
|
-
this._dialogElement.style[propertyName] = dialogState[propertyName] || '';
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const contentElement = this._contentElement || Selectors.find('.vg-modal-content', this._dialogElement);
|
|
208
|
-
if (contentElement) {
|
|
209
|
-
Object.keys(contentState).forEach(propertyName => {
|
|
210
|
-
contentElement.style[propertyName] = contentState[propertyName] || '';
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export default VGModalInteraction;
|
|
1
|
+
import Selectors from "../../../utils/js/dom/selectors";
|
|
2
|
+
import VGModalDrag from "./vgmodal.drag";
|
|
3
|
+
import VGModalResize from "./vgmodal.resize";
|
|
4
|
+
|
|
5
|
+
const DEFAULTS = {
|
|
6
|
+
drag: {
|
|
7
|
+
enable: false,
|
|
8
|
+
selector: '.vg-modal-content',
|
|
9
|
+
threshold: 4,
|
|
10
|
+
resizeEdgeSize: 8,
|
|
11
|
+
debug: false,
|
|
12
|
+
},
|
|
13
|
+
resize: {
|
|
14
|
+
enable: false,
|
|
15
|
+
edgeSize: 8,
|
|
16
|
+
minWidth: 300,
|
|
17
|
+
minHeight: 160,
|
|
18
|
+
debug: false,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class VGModalInteraction {
|
|
23
|
+
constructor(modalElement, dialogElement, contentElement, getParams) {
|
|
24
|
+
this._modalElement = modalElement;
|
|
25
|
+
this._dialogElement = dialogElement;
|
|
26
|
+
this._contentElement = contentElement;
|
|
27
|
+
this._getParams = typeof getParams === 'function' ? getParams : () => ({});
|
|
28
|
+
this._dragHandler = new VGModalDrag(this._modalElement, this._dialogElement);
|
|
29
|
+
this._resizeHandler = new VGModalResize(this._modalElement, this._dialogElement);
|
|
30
|
+
this._config = this._resolveConfig();
|
|
31
|
+
|
|
32
|
+
this._bindHandlers();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
toggleHandlers() {
|
|
36
|
+
this._config = this._resolveConfig();
|
|
37
|
+
this._bindHandlers();
|
|
38
|
+
|
|
39
|
+
if (this._config.drag.enable) {
|
|
40
|
+
this._dragHandler.enable();
|
|
41
|
+
} else {
|
|
42
|
+
this._dragHandler.disable();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (this._config.resize.enable) {
|
|
46
|
+
this._resizeHandler.enable();
|
|
47
|
+
} else {
|
|
48
|
+
this._resizeHandler.disable();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
disableHandlers() {
|
|
53
|
+
this._dragHandler.disable();
|
|
54
|
+
this._resizeHandler.disable();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
syncBounds() {
|
|
58
|
+
if (this._config.resize.enable) {
|
|
59
|
+
this._resizeHandler.syncToViewport();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (this._config.drag.enable) {
|
|
63
|
+
this._dragHandler.syncPosition();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
saveState() {
|
|
68
|
+
const stateConfig = this._getStateConfig();
|
|
69
|
+
const storageKey = this._getStateStorageKey(stateConfig);
|
|
70
|
+
if (!stateConfig.enable || !storageKey || typeof window === 'undefined' || !window.localStorage) return;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
window.localStorage.setItem(storageKey, JSON.stringify(this._captureState()));
|
|
74
|
+
} catch (error) {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
restoreState() {
|
|
79
|
+
const stateConfig = this._getStateConfig();
|
|
80
|
+
const storageKey = this._getStateStorageKey(stateConfig);
|
|
81
|
+
if (!stateConfig.enable || !storageKey || typeof window === 'undefined' || !window.localStorage) return false;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const rawState = window.localStorage.getItem(storageKey);
|
|
85
|
+
if (!rawState) return false;
|
|
86
|
+
|
|
87
|
+
const parsedState = JSON.parse(rawState);
|
|
88
|
+
this._applyState(parsedState);
|
|
89
|
+
return true;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
dispose() {
|
|
96
|
+
this.disableHandlers();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_bindHandlers() {
|
|
100
|
+
this._dragHandler.setOptions(this._config.drag);
|
|
101
|
+
this._resizeHandler.setOptions(this._config.resize);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_resolveConfig() {
|
|
105
|
+
const params = this._getParams();
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
drag: this._normalizeInteractionParams(params.drag, DEFAULTS.drag),
|
|
109
|
+
resize: this._normalizeInteractionParams(params.resize, DEFAULTS.resize),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_normalizeInteractionParams(paramsValue, defaults) {
|
|
114
|
+
if (typeof paramsValue === 'boolean') {
|
|
115
|
+
return {...defaults, enable: paramsValue};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (paramsValue && typeof paramsValue === 'object') {
|
|
119
|
+
const hasEnable = Object.prototype.hasOwnProperty.call(paramsValue, 'enable');
|
|
120
|
+
return {
|
|
121
|
+
...defaults,
|
|
122
|
+
...paramsValue,
|
|
123
|
+
enable: hasEnable ? Boolean(paramsValue.enable) : true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {...defaults};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_getStateConfig() {
|
|
131
|
+
const params = this._getParams();
|
|
132
|
+
return this._normalizeStateParams(params.state);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_normalizeStateParams(paramsValue, defaults = { enable: true, key: '' }) {
|
|
136
|
+
if (typeof paramsValue === 'boolean') {
|
|
137
|
+
return {...defaults, enable: paramsValue};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (paramsValue && typeof paramsValue === 'object') {
|
|
141
|
+
const hasEnable = Object.prototype.hasOwnProperty.call(paramsValue, 'enable');
|
|
142
|
+
const key = typeof paramsValue.key === 'string' ? paramsValue.key.trim() : '';
|
|
143
|
+
return {
|
|
144
|
+
...defaults,
|
|
145
|
+
...paramsValue,
|
|
146
|
+
key,
|
|
147
|
+
enable: hasEnable ? Boolean(paramsValue.enable) : true,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {...defaults};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_getStateStorageKey(stateConfig = this._getStateConfig()) {
|
|
155
|
+
if (!stateConfig.enable) return '';
|
|
156
|
+
|
|
157
|
+
if (typeof stateConfig.key === 'string' && stateConfig.key.trim()) {
|
|
158
|
+
return stateConfig.key.trim();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!this._modalElement || !this._modalElement.id) return '';
|
|
162
|
+
|
|
163
|
+
return `vg.modal.state:${window.location.pathname}:${this._modalElement.id}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_captureState() {
|
|
167
|
+
const dialogStyle = this._dialogElement ? this._dialogElement.style : null;
|
|
168
|
+
const contentElement = this._contentElement || Selectors.find('.vg-modal-content', this._dialogElement);
|
|
169
|
+
const contentStyle = contentElement ? contentElement.style : null;
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
dialog: dialogStyle ? {
|
|
173
|
+
position: dialogStyle.position,
|
|
174
|
+
margin: dialogStyle.margin,
|
|
175
|
+
left: dialogStyle.left,
|
|
176
|
+
top: dialogStyle.top,
|
|
177
|
+
width: dialogStyle.width,
|
|
178
|
+
height: dialogStyle.height,
|
|
179
|
+
transform: dialogStyle.transform,
|
|
180
|
+
maxWidth: dialogStyle.maxWidth,
|
|
181
|
+
maxHeight: dialogStyle.maxHeight,
|
|
182
|
+
minHeight: dialogStyle.minHeight,
|
|
183
|
+
overflow: dialogStyle.overflow,
|
|
184
|
+
pointerEvents: dialogStyle.pointerEvents,
|
|
185
|
+
transition: dialogStyle.transition,
|
|
186
|
+
willChange: dialogStyle.willChange,
|
|
187
|
+
} : {},
|
|
188
|
+
content: contentStyle ? {
|
|
189
|
+
height: contentStyle.height,
|
|
190
|
+
maxHeight: contentStyle.maxHeight,
|
|
191
|
+
overflow: contentStyle.overflow,
|
|
192
|
+
} : {},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_applyState(state) {
|
|
197
|
+
if (!state || typeof state !== 'object') return;
|
|
198
|
+
|
|
199
|
+
const dialogState = state.dialog && typeof state.dialog === 'object' ? state.dialog : {};
|
|
200
|
+
const contentState = state.content && typeof state.content === 'object' ? state.content : {};
|
|
201
|
+
if (this._dialogElement) {
|
|
202
|
+
Object.keys(dialogState).forEach(propertyName => {
|
|
203
|
+
this._dialogElement.style[propertyName] = dialogState[propertyName] || '';
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const contentElement = this._contentElement || Selectors.find('.vg-modal-content', this._dialogElement);
|
|
208
|
+
if (contentElement) {
|
|
209
|
+
Object.keys(contentState).forEach(propertyName => {
|
|
210
|
+
contentElement.style[propertyName] = contentState[propertyName] || '';
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default VGModalInteraction;
|