@topvisor/ui 0.0.15 → 0.0.17
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/.chunks/core-0b2c7817.es.js +152 -0
- package/.chunks/core-0b2c7817.es.js.map +1 -0
- package/.chunks/core-51f7b679.amd.js +151 -0
- package/.chunks/core-51f7b679.amd.js.map +1 -0
- package/.chunks/{forms-5e17154c.es.js → forms-245e3bc0.es.js} +175 -32
- package/.chunks/forms-245e3bc0.es.js.map +1 -0
- package/.chunks/forms-f7b7b259.amd.js +568 -0
- package/.chunks/forms-f7b7b259.amd.js.map +1 -0
- package/.chunks/popup-8f650530.amd.js +728 -0
- package/.chunks/popup-8f650530.amd.js.map +1 -0
- package/.chunks/popup-d240ed19.es.js +731 -0
- package/.chunks/popup-d240ed19.es.js.map +1 -0
- package/README.md +62 -62
- package/common/common.amd.js +1 -1
- package/core/core.amd.js +5 -0
- package/core/core.amd.js.map +1 -0
- package/core/core.js +7 -0
- package/core/core.js.map +1 -0
- package/core.css +647 -658
- package/dark.css +135 -135
- package/editArea/editArea.amd.js +126 -0
- package/editArea/editArea.amd.js.map +1 -0
- package/editArea/editArea.js +123 -0
- package/editArea/editArea.js.map +1 -0
- package/editArea.css +61 -0
- package/forms/forms.amd.js +5 -3
- package/forms/forms.amd.js.map +1 -1
- package/forms/forms.js +6 -4
- package/{helpers → forms}/helpers.amd.js +2 -2
- package/{helpers → forms}/helpers.js +1 -1
- package/forms.css +344 -254
- package/icomoon/demo-files/demo.css +161 -161
- package/icomoon/demo-files/demo.js +30 -30
- package/icomoon/demo.html +2945 -2931
- package/icomoon/fonts/Topvisor-2.svg +232 -231
- package/icomoon/fonts/Topvisor-2.ttf +0 -0
- package/icomoon/fonts/Topvisor-2.woff +0 -0
- package/icomoon/selection.json +1 -1
- package/icomoon/style.css +647 -644
- package/light.css +135 -135
- package/package.json +19 -19
- package/popup/popup.amd.js +198 -0
- package/popup/popup.amd.js.map +1 -0
- package/popup/popup.js +198 -0
- package/popup/popup.js.map +1 -0
- package/popup/worker.amd.js +234 -0
- package/popup/worker.amd.js.map +1 -0
- package/popup/worker.js +237 -0
- package/popup/worker.js.map +1 -0
- package/popup.css +19 -0
- package/tabs/tabs.amd.js +123 -0
- package/tabs/tabs.amd.js.map +1 -0
- package/tabs/tabs.js +120 -0
- package/tabs/tabs.js.map +1 -0
- package/tabs.css +60 -0
- package/utils/device.amd.js +42 -0
- package/utils/device.amd.js.map +1 -0
- package/utils/device.js +41 -0
- package/utils/device.js.map +1 -0
- package/utils/dom.amd.js +95 -0
- package/utils/dom.amd.js.map +1 -0
- package/utils/dom.js +94 -0
- package/utils/dom.js.map +1 -0
- package/.chunks/forms-2abb7eaa.amd.js +0 -425
- package/.chunks/forms-2abb7eaa.amd.js.map +0 -1
- package/.chunks/forms-5e17154c.es.js.map +0 -1
- package/icomoon/demo-files/Read Me.txt +0 -7
- /package/{helpers → forms}/helpers.amd.js.map +0 -0
- /package/{helpers → forms}/helpers.js.map +0 -0
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
define(["exports", "./core-51f7b679.amd", "../utils/dom.amd", "../popup/worker.amd", "vue", "../utils/device.amd"], function(exports, core_core, utils_dom, popup_worker, vue, utils_device) {
|
|
2
|
+
"use strict";
|
|
3
|
+
class Component {
|
|
4
|
+
static componentName = "Top";
|
|
5
|
+
componentName;
|
|
6
|
+
// имя класса компонента
|
|
7
|
+
className;
|
|
8
|
+
// имя css класса компонента
|
|
9
|
+
uid;
|
|
10
|
+
// уникальный id компонента
|
|
11
|
+
el;
|
|
12
|
+
// элемент, связанный с компонентом
|
|
13
|
+
options = {};
|
|
14
|
+
// параметры компонента
|
|
15
|
+
unmountEls = [];
|
|
16
|
+
unmountEvents = [];
|
|
17
|
+
// переопредлять нельзя
|
|
18
|
+
// если компонент инициирован, необходимо сразу его вернуть и выполнить reInit() вместо mount()
|
|
19
|
+
// используется init вместо constructor, так как super constructor выполняется до Object.defineProperty() параметров класса
|
|
20
|
+
init(componentName, el, options) {
|
|
21
|
+
if (!el) {
|
|
22
|
+
throw componentName + ": el is undefined";
|
|
23
|
+
}
|
|
24
|
+
const component = Component.getComponent(el, componentName);
|
|
25
|
+
if (component) {
|
|
26
|
+
component.reInit(options);
|
|
27
|
+
return component;
|
|
28
|
+
}
|
|
29
|
+
this.componentName = componentName;
|
|
30
|
+
this.className = "top" + componentName[0].toUpperCase() + componentName.substring(1);
|
|
31
|
+
this.uid = this.componentName + (Math.random() + "").replace(".", "");
|
|
32
|
+
this.#setComponent(el);
|
|
33
|
+
this.el = el;
|
|
34
|
+
this.el.classList.add(this.className);
|
|
35
|
+
this.options = Object.assign(this.options, options);
|
|
36
|
+
this.mount();
|
|
37
|
+
}
|
|
38
|
+
// получить инициированный компонент
|
|
39
|
+
static getComponent(el, componentName) {
|
|
40
|
+
return utils_dom.storage(el, "#" + componentName);
|
|
41
|
+
}
|
|
42
|
+
// устанвоить компонент
|
|
43
|
+
#setComponent(el) {
|
|
44
|
+
utils_dom.storage(el, "#" + this.componentName, this);
|
|
45
|
+
}
|
|
46
|
+
// функция подключения компонента
|
|
47
|
+
mount() {
|
|
48
|
+
throw "Please, add method mount() to component: " + this.componentName;
|
|
49
|
+
}
|
|
50
|
+
// функция отключения компонента
|
|
51
|
+
unmount() {
|
|
52
|
+
utils_dom.storage(this.el, "#" + this.componentName, null);
|
|
53
|
+
this.unmountEls.forEach((el) => {
|
|
54
|
+
el.remove();
|
|
55
|
+
});
|
|
56
|
+
this.unmountEls = [];
|
|
57
|
+
this.unmountEvents.forEach((eventData) => {
|
|
58
|
+
eventData.el.removeEventListener(eventData.type, eventData.listener, eventData.options);
|
|
59
|
+
});
|
|
60
|
+
this.unmountEvents = [];
|
|
61
|
+
}
|
|
62
|
+
// указание новые элементы, которые должны будут удалиться после unmount
|
|
63
|
+
registerElForUnmount(el) {
|
|
64
|
+
this.unmountEls.push(el);
|
|
65
|
+
}
|
|
66
|
+
// указание новые события, которые должны будут удалиться после unmount
|
|
67
|
+
addEventListenerWithUnmount(el, type, listener, options) {
|
|
68
|
+
el.addEventListener(type, listener, options);
|
|
69
|
+
this.registerEventForUnmount(el, type, listener, options);
|
|
70
|
+
}
|
|
71
|
+
// указание новые события, которые должны будут удалиться после unmount
|
|
72
|
+
registerEventForUnmount(el, type, listener, options) {
|
|
73
|
+
const eventData = {
|
|
74
|
+
el,
|
|
75
|
+
type,
|
|
76
|
+
listener,
|
|
77
|
+
options
|
|
78
|
+
};
|
|
79
|
+
this.unmountEvents.push(eventData);
|
|
80
|
+
}
|
|
81
|
+
// функция перенастройки уже подключенного компонента
|
|
82
|
+
reInit(_options) {
|
|
83
|
+
throw "Please, add method reInit() to component: " + this.componentName;
|
|
84
|
+
}
|
|
85
|
+
// удалить элементы из DOM, но не из памяти
|
|
86
|
+
static detach(nodes) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (nodes.forEach) {
|
|
89
|
+
nodes.forEach((node) => {
|
|
90
|
+
var _a2;
|
|
91
|
+
return (_a2 = node.parentElement) == null ? void 0 : _a2.removeChild(node);
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
const el = nodes;
|
|
95
|
+
(_a = el.parentElement) == null ? void 0 : _a.removeChild(el);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
class GlobalEvents {
|
|
100
|
+
static init() {
|
|
101
|
+
document.addEventListener("click", this.onclick);
|
|
102
|
+
document.addEventListener("keydown", this.onkeydown);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Глобальный обработчик кликов
|
|
106
|
+
* обрабатывает клики внутри Popup
|
|
107
|
+
* @param {Event} e
|
|
108
|
+
*/
|
|
109
|
+
static onclick(e) {
|
|
110
|
+
var _a;
|
|
111
|
+
const elCloser = e.target.closest(".closer, a, .a, .top-button");
|
|
112
|
+
if (elCloser) {
|
|
113
|
+
const elPopup = e.target.closest(".top-popup-wrapper");
|
|
114
|
+
if (!elPopup) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (elCloser.matches(".top-popup-noCloser")) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (elCloser.getAttribute("href") === ".") {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
}
|
|
123
|
+
if (e.target.matches("[data-top-popup]")) {
|
|
124
|
+
const elUl = e.target.closest("ul");
|
|
125
|
+
const elItem = e.target.closest("a, .a");
|
|
126
|
+
if (elUl) {
|
|
127
|
+
(_a = elUl.querySelector("a.top-active, .a.top-active")) == null ? void 0 : _a.classList.remove("top-active");
|
|
128
|
+
}
|
|
129
|
+
if (elItem) {
|
|
130
|
+
elItem.classList.add("top-active");
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
popup_worker.close(elPopup);
|
|
135
|
+
}
|
|
136
|
+
if (e.target.matches(".top-popup-wrapper")) {
|
|
137
|
+
const elPopup = e.target;
|
|
138
|
+
popup_worker.close(elPopup);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Глобальный обработчик нажатия кнопки на клавиатуре
|
|
143
|
+
* @param {Event} e
|
|
144
|
+
*/
|
|
145
|
+
static onkeydown(e) {
|
|
146
|
+
var _a;
|
|
147
|
+
const elPopup = e.target.closest(".top-popup-wrapper");
|
|
148
|
+
if (!elPopup) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const elUl = elPopup.querySelector("ul.top-popup_content");
|
|
152
|
+
switch (e.key) {
|
|
153
|
+
case "Escape":
|
|
154
|
+
break;
|
|
155
|
+
case "Enter":
|
|
156
|
+
if (!elUl) {
|
|
157
|
+
if (utils_dom.querySelectorVisible(elPopup, ".preloader")) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
const elBtn = elPopup.querySelector(".top-popup_footer .go, .top-popup_footer [data-action]");
|
|
161
|
+
if (elBtn) {
|
|
162
|
+
elBtn.click();
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
const elLink = utils_dom.querySelectorVisible(elPopup, "li > a.top-active");
|
|
167
|
+
if (elLink) {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
location.href = elLink.getAttribute("href");
|
|
170
|
+
}
|
|
171
|
+
const elItem = elPopup.querySelector("li > .top-active");
|
|
172
|
+
if (elItem) {
|
|
173
|
+
elItem.click();
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case "ArrowUp":
|
|
177
|
+
case "ArrowRight":
|
|
178
|
+
case "ArrowDown":
|
|
179
|
+
case "ArrowLeft":
|
|
180
|
+
if (!elUl) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
|
|
184
|
+
const elMoreVisible = utils_dom.querySelectorVisible(elPopup, "ul.top-popup_content > li:not(.top-popup_listTitle):not(.top-popup_listDelimiter) > .top-active > .top-popup_listMore");
|
|
185
|
+
if (elMoreVisible) {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
}
|
|
191
|
+
const elItemActive = (_a = elPopup.querySelector("ul.top-popup_content > li:not(.top-popup_listTitle):not(.top-popup_listDelimiter) > .top-active")) == null ? void 0 : _a.parentElement;
|
|
192
|
+
if (e.key === "ArrowRight" && elItemActive) {
|
|
193
|
+
const elMore = elItemActive.querySelector(".top-active > .top-popup_listMore");
|
|
194
|
+
if (elMore) {
|
|
195
|
+
return elMore.click();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const elsLiVisible = utils_dom.querySelectorAllVisible(elPopup, "ul.top-popup_content > li:not(.top-popup_listTitle):not(.top-popup_listDelimiter)");
|
|
199
|
+
const countLi = elsLiVisible.length;
|
|
200
|
+
let index = elsLiVisible.indexOf(elItemActive);
|
|
201
|
+
if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
202
|
+
index--;
|
|
203
|
+
} else {
|
|
204
|
+
index++;
|
|
205
|
+
}
|
|
206
|
+
if (e.key === "ArrowLeft" && index === -1) {
|
|
207
|
+
if (e.target.matches("input")) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
return popup_worker.close(elPopup);
|
|
211
|
+
}
|
|
212
|
+
if (e.key === "ArrowRight" && index === countLi) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (index < 0) {
|
|
216
|
+
index = countLi - 1;
|
|
217
|
+
}
|
|
218
|
+
if (index > countLi - 1) {
|
|
219
|
+
index = 0;
|
|
220
|
+
}
|
|
221
|
+
elPopup.querySelectorAll("ul.top-popup_content > li > .top-active").forEach((el) => el.classList.remove("top-active"));
|
|
222
|
+
elsLiVisible[index].querySelector(":scope > a, :scope > .a").classList.add("top-active");
|
|
223
|
+
popup_worker.scrollToActive(elPopup);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const css = ':root{\n --top-popup-background-color-hover: var(--color-steel-150);\n --top-popup-background-color-active: var(--color-steel-200);\n --top-popup-border-color: var(--color-theme-100);\n --top-popup-title-background-color: var(--color-steel-100);\n}\n\n.top-theme-dark{\n --top-popup-background-color-hover: var(--color-gray-800);\n --top-popup-background-color-active: var(--color-gray-750);\n --top-popup-title-background-color: var(--color-gray-900);\n}\n\n.top-popup-front{ position: relative; }\n\n.top-popup-wrapper{\n --top-popup-background-color: var(--color-bg-3);\n\n --top-popup-padding-h: 8px;\n --top-popup-padding-v: 8px;\n\n /* см. recalcPosition() */\n --top-popup-height: 0px;\n --top-popup-right-bounding: 0px;\n --top-popup-bottom-bounding: 0px;\n --top-popup-top: 0px;\n --top-popup-right: calc(100vw - var(--top-popup-right-bounding));\n --top-popup-bottom: calc(var(--100vh) - var(--top-popup-bottom-bounding));\n --top-popup-left: 0px;\n\n text-align: initial; white-space: normal; word-break: normal;\n position: absolute; z-index: 200000;\n}\n.top-popup-wrapper:not(.top-popup-wrapper-shown){ overflow: hidden; }\n\n/* top-popupPanel */\n.top-popupPanel {\n cursor: default;\n box-shadow: var(--top-shadow-b);\n border-radius: 8px;\n background: var(--top-popup-background-color);\n position: absolute; overflow: hidden;\n display: flex; flex-direction: column;\n}\n\n/* position */\n.top-popup-wrapper > *{ opacity: 0; transition: opacity 100ms linear, transform 100ms linear; }\n.top-popup-wrapper.p0 > *{ transform: translateY(-8px); }\n.top-popup-wrapper.p1 > *{ transform: translateY(8px); }\n.top-popup-wrapper.p2 > *{ transform: translateX(8px); }\n.top-popup-wrapper.p3 > *{ transform: translateY(8px); }\n.top-popup-wrapper.p4 > *{ transform: translateX(-8px); }\n.top-popup-wrapper-shown:not(.top-popup-wrapper-closed) > *{opacity: 1;transform: translate(0, 0) !important;}\n\n.top-popup-wrapper.p0 > .top-popup{ top: calc(-16px); left: calc(0px - var(--top-popup-padding-h)); }\n.top-popup-wrapper.p1 > .top-popup{ bottom: calc(100% + 8px); }\n.top-popup-wrapper.p2 > .top-popup{ left: calc(100% + 8px); }\n.top-popup-wrapper.p3 > .top-popup{ top: calc(100% + 8px); }\n.top-popup-wrapper.p4 > .top-popup{ right: calc(100% + 8px); }\n.top-popup-wrapper.p2 > .top-popup,\n.top-popup-wrapper.p4 > .top-popup{ margin-top: -10px; }\n\n.top-popup-wrapper.p1.with_notch > .top-popup{ margin-bottom: 5px; }\n.top-popup-wrapper.p2.with_notch > .top-popup{ margin-left: 5px; }\n.top-popup-wrapper.p3.with_notch > .top-popup{ margin-top: 5px; }\n.top-popup-wrapper.p4.with_notch > .top-popup{ margin-right: 5px; }\n\n.top-popup-wrapper.invert-x > .top-popup{ right: 0; }\n.top-popup-wrapper.invert-y > .top-popup{ bottom: 0; }\n\n/* notch */\n.top-popup-wrapper > .notch{ border: 7.4px solid transparent; position: absolute; display: block; }\n\n.top-popup-wrapper.p1 > .notch{ border-bottom: 0; border-top: 7.4px solid var(--content-background-color); margin: 0 0 7.4px -7.4px; bottom: 100%; left: 50% }\n.top-popup-wrapper.p2 > .notch{ border-left: 0; border-right: 7.4px solid var(--content-background-color); margin: 0 0 -7.4px 7.4px; bottom: 50%; left: 100%; }\n.top-popup-wrapper.p3 > .notch{ border-top: 0; border-bottom: 7.4px solid var(--content-background-color); margin: 7.4px 0 0 -7.4px; top: 100%; left: 50%; }\n.top-popup-wrapper.p4 > .notch{ border-right: 0; border-left: 7.4px solid var(--content-background-color); margin: 0 7.4px -7.4px 0; bottom: 50%; right: 100%; }\n\n.top-popup-wrapper.p1 > .notch-border{ border-top-color: rgba(0,0,0,0.05); margin-bottom: 6px; }\n.top-popup-wrapper.p2 > .notch-border{ border-right-color: rgba(0,0,0,0.05); margin-left: 6px; }\n.top-popup-wrapper.p3 > .notch-border{ border-bottom-color: rgba(0,0,0,0.05); margin-top: 6px; }\n.top-popup-wrapper.p4 > .notch-border{ border-left-color: rgba(0,0,0,0.05); margin-right: 6px; }\n\n/* common */\n.top-popup_header,\n.top-popup_content,\n.top-popup_footer{ padding: var(--top-popup-padding-h) var(--top-popup-padding-h); font-size: 14px; }\n.top-popup_header,\n.top-popup_footer{ display: flex; align-items: center; justify-content: space-between; }\n\n/* header */\n.top-popup_header{ border-bottom: 1px solid var(--top-popup-border-color); font-weight: 600; }\n.top-popup_header > *{ font-weight: 400; }\n.top-popup_header > .a{ cursor: pointer; color: var(--color-blue-450); }\n.top-popup_header > .a:hover{ color: var(--color-blue-350); }\n\n.top-popup-headerButton{ width: 60px; }\n\n/* content */\n.top-popup .top-popup_content{\n /* has_scroll */\n --scroll-padding-top: var(--top-popup-padding-v);\n --scroll-padding-bottom: var(--top-popup-padding-v);\n\n padding-top: var(--top-popup-padding-v); padding-bottom: var(--top-popup-padding-v); margin: 0; line-height:1.3 !important;\n flex-grow: 1; overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n}\n\n.top-popup .top-popup_content .top-unwrap{\n --top-unwrap-x: var(--top-popup-padding-h);\n}\n\n.top-popup div.top-popup_content{ display: flex; flex-direction: column; gap: 4px; }\n.top-popup div.top-popup_content > *{ flex-shrink: 0; }\n.top-popup div.top-popup_content > .top-button{ margin: 0; }\n\n.top-popup ul.top-popup_content{\n --scroll-padding-top: 4px;\n --scroll-padding-bottom: var(--scroll-padding-top);\n\n padding: var(--scroll-padding-top) 0;\n}\n\nul.top-popup_content li{ margin: 0; list-style:none; display: flex; position: relative }\nul.top-popup_content li > *{ flex-grow: 1; }\nul.top-popup_content li > a:not(.top-button),\nul.top-popup_content li > i.a{\n cursor: pointer;\n box-sizing: border-box;\n background: var(--top-popup-background-color); padding:var(--top-popup-padding-v) var(--top-popup-padding-h);\n color:var(--color-text) !important; font-size: 14px; font-weight: normal !important; text-decoration:none !important; font-style: normal;\n display:flex; flex: 1 1 100%; align-items: center;\n transition: background-color 0.1s ease-in-out;\n}\n.top-popup-wrapper-no_animate ul.top-popup_content li > a:not(.top-button),\n.top-popup-wrapper-no_animate ul.top-popup_content li > i.a{ transition: none; }\n\nul.top-popup_content li > a:not(.top-button):hover,\nul.top-popup_content li > i.a:hover{ background: var(--top-popup-background-color-hover); }\nul.top-popup_content li > a:not(.top-button).top-active,\nul.top-popup_content li > i.a.top-active{ background: var(--top-popup-background-color-active); }\n\n/* listTitle */\nli.top-popup_listTitle{\n background: var(--top-popup-title-background-color); padding: var(--top-popup-padding-v) var(--top-popup-padding-h);\n color: var(--color-text-3); font-size: 12px; font-weight: 400;\n}\nli.top-popup_listTitle:first-child{\n padding-top: calc(var(--top-popup-padding-v) + var(--scroll-padding-top));\n margin-top: calc(0px - var(--scroll-padding-top));\n}\n\n/* listDelimiter */\nul.top-popup_content li.top-popup_listDelimiter{\n border-radius: 3px;\n background: var(--top-popup-border-color);\n height: 2px;\n margin: calc(var(--top-popup-padding-h) / 2) var(--top-popup-padding-h);\n}\n\n/* listMore */\nul.top-popup_content li > i.a.top-popup_listMore{\n height: auto; padding-right: 4px; padding-left: 4px;\n font-size: 24px; line-height: 17px; text-align: center;\n flex-basis: 10px;\n}\nul.top-popup_content li > i.a.top-popup_listMore:before{ color: var(--color-gray-500); }\nul.top-popup_content li > * > i.top-popup_listMore{\n padding: 0 var(--top-popup-padding-h); margin: 0 0 0 auto;\n color: var(--color-gray-500);\n font-size: 14px;\n}\nul.top-popup_content li > * > i.top-popup_listMore:hover,\nul.top-popup_content li > * > i.top-popup_listMore.top-active{ color: var(--color-blue-500); }\nul.top-popup_content li > * > i.top-popup_listMore:before{ transform: rotate(90deg); }\n\nul.top-popup_content li a.close{ background: none !important; }\n\n/* data-top-icon */\n.top-popup_content > [data-top-icon]:before{ --top-icon-size: 20px; }\n\nul.top-popup_content li > [data-top-icon]:not(.top-button):before{\n --top-icon-color: var(--color-text-3);\n --top-icon-size: 20px;\n --top-icon-width: 20px;\n\n height: 1rem; margin-right: 8px; transition: color 0.1s;\n}\nul.top-popup_content li:hover > [data-top-icon]:not(.top-button):before,\nul.top-popup_content li > [data-top-icon]:not(.top-button).top-active:before{\n --top-icon-color: #378DC6;\n}\n\n/* footer */\n.top-popup_footer{\n padding: var(--top-popup-padding-h) var(--top-popup-padding-h); display: flex; gap:8px; justify-content: flex-end;\n}\n.top-popup_footer > .top-button{ margin: 0; }\n\n/* Виджеты */\n.top-popup > [data-widget]{ padding: 0 var(--top-popup-padding-h); }\n.top-popup > [data-widget] + hr{ margin: 0 var(--top-popup-padding-h); }\n\n.top-popup .placeholder{\n border:1px solid #E0D9D9 !important; border-right: none !important; border-left: none !important; background:#F9F9F9 !important; margin: -1px 0; z-index: 1;\n position: relative;\n}\n\n/* компоненты */\n.top-popup-wrapper.simple_list > .top-popup{ min-width: 0; white-space: nowrap; }\n\n.top-popup_content .top-column{ display: flex; flex-direction: column; gap: 4px; }\n.top-popup_content li > :not(a):not(.a){ margin:0 var(--top-popup-padding-h); }\nhtml .top-popup .top-popup_content li > .top-button{ margin:calc(var(--top-popup-padding-v) / 2) var(--top-popup-padding-h); }\n\n.top-popup li .check_all,\n.top-popup li .clear_all{ cursor: pointer; color: var(--color-cyan); padding: 8px; display: inline-block; }\n.top-popup li .check_all:hover,\n.top-popup li .clear_all:hover{ text-decoration: underline; }\n.top-popup li .clear_all{ display: none; }\n\n/* table */\n.top-popup_content table{ margin: -9px 0; }\n.top-popup_content table td,\n.top-popup_content table th{ padding: 9px var(--top-popup-padding-h) 9px 0; vertical-align: top; }\n.top-popup_content table th{ width: 40%; font-weight: 600; white-space: nowrap; }\n\n/* формы */\nul.top-popup_content .a > [type="checkbox"],\nul.top-popup_content .a > [type="radio"]{ margin: -8px 0 -8px auto; }\n\n/* deprecated */\nul.top-popup_content a > [class*=icon],\nul.top-popup_content i.a > [class*=icon]{\n margin-right: 14px; text-align: center;\n width: auto; height: 16px; font-size: 16px; vertical-align: top;\n transition: 0.1s;\n}\n\n.top-popup .buttons{ border-radius:0 0 4px 4px; border-top:1px solid #BDC3C7; background:#ECF0F1; padding:10px 15px; margin:10px -15px -10px -15px; white-space: nowrap; }\n.top-popup_footer [class*=btn]:not(.btn-transparent){ min-width: 100px; padding: 5px 14px; margin-left: 10px; }\n.top-popup_footer [class*=btn]:first-child{ margin-left: 0; }\n.top-popup_footer .btn.full_width{ margin: 0; flex-grow: 1; }';
|
|
229
|
+
const cssM = "html.with_popup{ background: #808080; }\n\n.top-popup-wrapper{\n --top-popup-padding-h: 19px;\n --top-popup-padding-v: 16px;\n --top-popup-footer-offset: 25px;\n\n width: auto !important; height: auto !important;\n position: fixed; top: 0 !important; right: 0 !important; left: 0 !important; overflow: hidden;\n transition: background 0.3s;\n}\n\n.top-popup-wrapper-shown:not(.top-popup-wrapper-closed){ background: rgba(0,0,0,0.5); backdrop-filter: blur(1px); }\n.top-popup-wrapper-shown:not(.top-popup-wrapper-closed) > .top-popup{ opacity: 1 !important; }\n\n.top-popup{\n border-radius: 8px 8px 0 0; width: auto !important; max-height: calc(100% - var(--header-height) - 12px);\n top: auto !important; right: 0 !important; bottom: 0 !important; left: 0 !important;\n display: flex; flex-direction: column;\n\n /* невозможно опустить элемент вниз за экран на 100%, fix: opacity и translateY(80%) */\n transform: translateY(80%);\n\n transition: opacity 0.3s, transform 0.3s;\n}\n\n/* from top */\n.top-popup-wrapper.p-from-top{\n --top-popup-footer-offset: 0px;\n\n top: var(--header-height) !important;\n}\n.with_dialog .top-popup-wrapper.p-from-top{ top: 50px !important; }\n.top-popup-wrapper.p-from-top > .top-popup{\n border-radius: 0 0 8px 8px; max-height: calc(100% - 24px); top: 0 !important; bottom: auto !important;\n transform: translateY(calc(-100% - 24px));\n}\n\n.top-popup_content:last-child,\n.top-popup_footer{\n --scroll-padding-bottom: calc(var(--top-popup-padding-v) + var(--top-popup-footer-offset));\n\n padding-bottom: var(--scroll-padding-bottom);\n}\n\n/* content */\nul.top-popup_content{\n --scroll-padding-top: 0px;\n --scroll-padding-bottom: var(--scroll-padding-top);\n\n display: flex; flex-direction: column;\n}\nul.top-popup_content li:not(:last-child){ border-bottom: 1px solid var(--top-popup-border-color); }\n\n.top-popup-wrapper.top-style_alt > .top-popup > ul > li{ border-bottom: none; }\n\n/* footer */\n.top-popup_footer{ flex-wrap: wrap; }\n.top-popup_footer > .top-button{\n --top-forms-base-height: var(--top-forms-base-height_xl);\n\n flex-grow: 1;\n}\n\n/* listTitle */\nul.top-popup_content li.top-popup_listTitle{\n --top-popup-padding-v: 12px;\n}\n\n/* listDelimiter */\nul.top-popup_content li.top-popup_listDelimiter{ border-radius: 0; border-bottom: none; height: 2px; margin: 0; }";
|
|
230
|
+
const cssPC = "html:not(.with_dialog){ margin-right: 0 !important; }\n\n.top-popup{ min-width: 250px; max-width: calc(100vw - var(--top-popup-left) - 16px); max-height: calc(var(--top-popup-bottom) + var(--top-popup-height)); }\n.top-popup-wrapper.invert-x > .top-popup{ max-width: calc(100vw - var(--top-popup-right) - 16px); }\n.top-popup-wrapper.invert-y > .top-popup{ max-height: calc(100vh - var(--top-popup-bottom) - 16px); }\n\n/* position */\n.top-popup-wrapper.p1 > .top-popup{ max-height: calc(var(--top-popup-top) - var(--header-height) - 16px); }\n.top-popup-wrapper.p3 > .top-popup{ max-height: calc(var(--top-popup-bottom) - 16px); }\n.top-popup-wrapper.p2 > .top-popup{ max-width: calc(var(--top-popup-right) - 16px); }\n.top-popup-wrapper.p4 > .top-popup{ max-width: calc(var(--top-popup-left) - 16px); }\n\n/* notch */\n.top-popup-wrapper.p1.with_notch > .top-popup,\n.top-popup-wrapper.p3.with_notch > .top-popup{ margin-left: -16px !important; }\n.top-popup-wrapper.p1.with_notch > .notch,\n.top-popup-wrapper.p3.with_notch > .notch{ margin-left: -8px !important; }\n\n.top-popup-wrapper.p1.with_notch.invert-x,\n.top-popup-wrapper.p3.with_notch.invert-x{ margin-left: 3px !important; }\n.top-popup-wrapper.p1.with_notch.invert-x > .notch,\n.top-popup-wrapper.p3.with_notch.invert-x > .notch{ margin-left: -9px !important; }\n\n/* listMore */\nul.top-popup_content li > * > i.top-popup_listMore{ visibility: hidden; transition: none; }\nul.top-popup_content li:hover > * > i.top-popup_listMore,\nul.top-popup_content li > *.top-active > i.top-popup_listMore,\nul.top-popup_content li > * > i.top-popup_listMore.top-active{ visibility: visible; }";
|
|
231
|
+
core_core.Core.appendStyle(css);
|
|
232
|
+
core_core.Core.appendStyle(cssM, "m");
|
|
233
|
+
core_core.Core.appendStyle(cssPC, "pc");
|
|
234
|
+
class Popup extends Component {
|
|
235
|
+
static componentName = "Popup";
|
|
236
|
+
el;
|
|
237
|
+
// элемент, вызвавший открытие Popup
|
|
238
|
+
elActiveByDefault;
|
|
239
|
+
// элемент уже имеет класс top-active перед открытием окна
|
|
240
|
+
elPopup;
|
|
241
|
+
elPopupInner;
|
|
242
|
+
elPopupHeader;
|
|
243
|
+
elPopupBody;
|
|
244
|
+
elPopupFooter;
|
|
245
|
+
elFront;
|
|
246
|
+
popupParent;
|
|
247
|
+
$;
|
|
248
|
+
// только, если есть jQuery
|
|
249
|
+
elStartPosition;
|
|
250
|
+
// используется для useOriginal
|
|
251
|
+
shift = {
|
|
252
|
+
top: 0,
|
|
253
|
+
left: 0
|
|
254
|
+
};
|
|
255
|
+
isClosed = false;
|
|
256
|
+
// флаг того, что меню закрыто
|
|
257
|
+
isFirstClick = true;
|
|
258
|
+
type;
|
|
259
|
+
// selector или html
|
|
260
|
+
options = {
|
|
261
|
+
popup: "",
|
|
262
|
+
// selector, text
|
|
263
|
+
p: 0,
|
|
264
|
+
// положение меню (0 - над элементом, 1 - сверху, 2 - справа, 3 - снизу, 4 слева)
|
|
265
|
+
notch: false,
|
|
266
|
+
// отображать ли клювик
|
|
267
|
+
class: "",
|
|
268
|
+
// класс, добавляемый меню
|
|
269
|
+
posBy: "left",
|
|
270
|
+
// способ привязки позиционирования меню (left/right - левый/правый край родителя, fixed - по окну)
|
|
271
|
+
frontSelector: "",
|
|
272
|
+
invertX: false,
|
|
273
|
+
// базовая ордината - правая граница элемента, а не левая
|
|
274
|
+
openByHover: false,
|
|
275
|
+
// открывать при наведении
|
|
276
|
+
useOriginal: false,
|
|
277
|
+
// использовать оригинальный шаблон, без клонирвоания (для сохранения состояния меню)
|
|
278
|
+
isFullScreen: false,
|
|
279
|
+
i18n: {}
|
|
280
|
+
};
|
|
281
|
+
events = {};
|
|
282
|
+
// el - элемент, открывающий меню
|
|
283
|
+
constructor(el, options) {
|
|
284
|
+
super();
|
|
285
|
+
return this.init(Popup.componentName, el, options);
|
|
286
|
+
}
|
|
287
|
+
async mount() {
|
|
288
|
+
const vueConnector = this.vueGetComponent();
|
|
289
|
+
this.popupParent = popup_worker.getPopup(this.el.closest(".top-popup-wrapper"));
|
|
290
|
+
await this.mountJQuery();
|
|
291
|
+
if (utils_dom.css(this.el, "position") !== "absolute") {
|
|
292
|
+
this.el.style.position = "relative";
|
|
293
|
+
}
|
|
294
|
+
this.el.dataset.topPopupOpened = "opened";
|
|
295
|
+
this.elActiveByDefault = this.el.classList.contains("top-active");
|
|
296
|
+
this.el.classList.add("top-active");
|
|
297
|
+
if (vueConnector) {
|
|
298
|
+
this.type = "vue";
|
|
299
|
+
this.options.popup = "";
|
|
300
|
+
this.elPopup = utils_dom.genEl("div", {}, this.options.popup);
|
|
301
|
+
} else if (this.options.popup.match(/^[#.]/)) {
|
|
302
|
+
this.type = "selector";
|
|
303
|
+
this.elPopup = document.querySelector(`${this.options.popup}.template`);
|
|
304
|
+
} else {
|
|
305
|
+
this.type = "html";
|
|
306
|
+
if (this.options.useOriginal) {
|
|
307
|
+
throw "Option useOriginal not allowed for text templates";
|
|
308
|
+
}
|
|
309
|
+
this.elPopup = utils_dom.genEl("div", {}, this.options.popup);
|
|
310
|
+
}
|
|
311
|
+
if (!this.elPopup || (vueConnector == null ? void 0 : vueConnector.opened)) {
|
|
312
|
+
if (this.options.useOriginal || (vueConnector == null ? void 0 : vueConnector.opened)) {
|
|
313
|
+
if (vueConnector == null ? void 0 : vueConnector.opened) {
|
|
314
|
+
this.elPopup = vueConnector.popup.elPopup;
|
|
315
|
+
} else {
|
|
316
|
+
this.elPopup = document.querySelector(`${this.options.popup}.top-popup-wrapper-shown`);
|
|
317
|
+
}
|
|
318
|
+
if (this.elPopup) {
|
|
319
|
+
this.el.dataset.topPopupOpened = "";
|
|
320
|
+
if (!this.elActiveByDefault) {
|
|
321
|
+
this.el.classList.remove("top-active");
|
|
322
|
+
}
|
|
323
|
+
popup_worker.close(this.elPopup);
|
|
324
|
+
setTimeout(() => this.mount(), 300);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
throw "Option useOriginal state allowed only elements .template";
|
|
328
|
+
}
|
|
329
|
+
this.elPopup = document.querySelector(`${this.options.popup}:not(.top-popup-wrapper)`);
|
|
330
|
+
}
|
|
331
|
+
if (!this.elPopup) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (this.options.useOriginal) {
|
|
335
|
+
this.elStartPosition = this.elPopup.closest(".top-popup-el-start-position");
|
|
336
|
+
if (!this.elStartPosition) {
|
|
337
|
+
this.elStartPosition = utils_dom.wrap(this.elPopup, "i");
|
|
338
|
+
this.elStartPosition.classList.add("top-popup-el-start-position", "hidden");
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
this.elPopup = this.elPopup.cloneNode(true);
|
|
342
|
+
if (this.type === "selector" && !this.elPopup.matches(".template")) {
|
|
343
|
+
this.elPopup.classList.remove("hidden");
|
|
344
|
+
if (!this.elPopup.querySelector(":scope > .top-popup_content")) {
|
|
345
|
+
this.elPopup.classList.add("top-popup_content");
|
|
346
|
+
}
|
|
347
|
+
this.elPopup = utils_dom.wrap(this.elPopup, "div");
|
|
348
|
+
}
|
|
349
|
+
if (this.type === "html") {
|
|
350
|
+
if (!this.elPopup.querySelector(":scope > .top-popup_content")) {
|
|
351
|
+
this.elPopup.classList.add("top-popup_content");
|
|
352
|
+
this.elPopup = utils_dom.wrap(this.elPopup, "div");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (this.type === "selector" && !this.elPopup.matches(".template") || this.type === "html" || this.type === "vue") {
|
|
356
|
+
utils_dom.querySelectorAllArray(this.elPopup, "[data-top-popup]").forEach((el) => el.dataset.topPopupPosBy = "fixed");
|
|
357
|
+
utils_dom.querySelectorAllArray(this.elPopup, ".top-popup-wrapper").forEach((el) => el.remove());
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
popup_worker.decoratorBeforeOpen(this);
|
|
361
|
+
if (vueConnector) {
|
|
362
|
+
this.options.class = vueConnector.classRef.value;
|
|
363
|
+
}
|
|
364
|
+
this.elPopupInner = document.createElement("div");
|
|
365
|
+
this.elPopupInner.classList.add("top-popupPanel", "top-popup");
|
|
366
|
+
while (this.elPopup.firstChild) {
|
|
367
|
+
this.elPopupInner.appendChild(this.elPopup.firstChild);
|
|
368
|
+
}
|
|
369
|
+
this.elPopup.append(this.elPopupInner);
|
|
370
|
+
this.elPopup.classList.add("top-popup-wrapper");
|
|
371
|
+
if (this.options.class) {
|
|
372
|
+
const classes = this.options.class.split(" ");
|
|
373
|
+
this.elPopup.classList.add(...classes);
|
|
374
|
+
}
|
|
375
|
+
if (this.options.notch) {
|
|
376
|
+
this.elPopup.classList.add("with_notch");
|
|
377
|
+
this.elPopup.insertAdjacentHTML("beforeend", '<i class="notch notch-border"></i><i class="notch"></i>');
|
|
378
|
+
}
|
|
379
|
+
await this.vueOpen();
|
|
380
|
+
this.elPopupHeader = this.elPopupInner.querySelector(".top-popup_header");
|
|
381
|
+
this.elPopupBody = this.elPopupInner.querySelector(".top-popup_content");
|
|
382
|
+
this.elPopupFooter = this.elPopupInner.querySelector(".top-popup_footer");
|
|
383
|
+
const existsWidgetSearch = !!this.elPopup.querySelector('[data-widget="search"]');
|
|
384
|
+
if (this.options.isFullScreen && !existsWidgetSearch) {
|
|
385
|
+
if (!this.elPopupHeader) {
|
|
386
|
+
this.elPopupHeader = utils_dom.genEl("i", { class: "header" });
|
|
387
|
+
this.elPopupInner.prepend(this.elPopupHeader);
|
|
388
|
+
this.elPopupHeader.prepend(utils_dom.genEl("i", { class: "a closer" }, this.options.i18n.Close));
|
|
389
|
+
this.elPopupHeader.append(utils_dom.genEl("i", { class: "top-popup-headerButton" }));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
utils_dom.storage(this.elPopup, "Popup", this);
|
|
393
|
+
if (this.options.frontSelector) {
|
|
394
|
+
this.elFront = document.querySelector(this.options.frontSelector);
|
|
395
|
+
}
|
|
396
|
+
if (!this.elFront) {
|
|
397
|
+
this.elFront = this.el.closest(".top-popup-front");
|
|
398
|
+
}
|
|
399
|
+
if (!this.elFront) {
|
|
400
|
+
this.elFront = document.body;
|
|
401
|
+
}
|
|
402
|
+
this.elPopup.style.width = this.el.offsetWidth + "px";
|
|
403
|
+
this.elPopup.style.height = this.el.offsetHeight + "px";
|
|
404
|
+
this.elPopup.style.top = this.el.offsetTop + "px";
|
|
405
|
+
this.elPopup.style.right = parseInt(this.el.style.right || 0) + "px";
|
|
406
|
+
this.elPopup.style.bottom = parseInt(this.el.style.bottom || 0) + "px";
|
|
407
|
+
this.el.parentElement.insertBefore(this.elPopup, this.el);
|
|
408
|
+
this.elPopup.classList.remove("template");
|
|
409
|
+
if (this.options.invertX) {
|
|
410
|
+
this.elPopup.classList.add("invert-x");
|
|
411
|
+
}
|
|
412
|
+
let fromTop = !!this.el.closest(".modal-header");
|
|
413
|
+
if (!fromTop) {
|
|
414
|
+
fromTop = !!this.el.closest("#top_panel");
|
|
415
|
+
}
|
|
416
|
+
if (!fromTop) {
|
|
417
|
+
fromTop = !!this.el.closest("#secondmenu");
|
|
418
|
+
}
|
|
419
|
+
if (fromTop) {
|
|
420
|
+
this.elPopup.classList.add("p-from-top");
|
|
421
|
+
}
|
|
422
|
+
setTimeout(() => this.elPopup.classList.add("top-popup-wrapper-shown"));
|
|
423
|
+
if (this.elFront && !this.elFront.matches("body")) {
|
|
424
|
+
this.elFront.append(this.elPopup);
|
|
425
|
+
this.shift.top = utils_dom.offset(this.el).top - this.el.offsetTop - utils_dom.offset(this.elFront).top;
|
|
426
|
+
this.shift.left = utils_dom.offset(this.el).left - this.el.offsetLeft - utils_dom.offset(this.elFront).left;
|
|
427
|
+
this.shift.top -= parseInt(this.el.style["margin-top"] || 0);
|
|
428
|
+
this.shift.left -= parseInt(this.el.style["margin-left"] || 0);
|
|
429
|
+
this.elPopup.style.top = parseInt(this.elPopup.style.top || "0") + this.shift.top + "px";
|
|
430
|
+
this.elPopup.style.left = parseInt(this.elPopup.style.left || "0") + this.shift.left + "px";
|
|
431
|
+
}
|
|
432
|
+
if (this.$) {
|
|
433
|
+
this.$.trigger("aftershow.top-menu-popup", [jQuery(this.elPopup)]);
|
|
434
|
+
}
|
|
435
|
+
this.recalcPosition();
|
|
436
|
+
this.elPopup.setAttribute("tabindex", 0);
|
|
437
|
+
this.focus();
|
|
438
|
+
popup_worker.decoratorAfterOpen(this);
|
|
439
|
+
this.mountEvents();
|
|
440
|
+
}
|
|
441
|
+
async mountJQuery() {
|
|
442
|
+
if (typeof jQuery !== "function") {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
this.$ = jQuery(this.el);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Выполнить фокусировку на нужный элемент после открытия окна
|
|
449
|
+
*/
|
|
450
|
+
focus() {
|
|
451
|
+
let el = utils_dom.querySelectorVisible(this.elPopup, ".top-popup-autofocus");
|
|
452
|
+
if (!el) {
|
|
453
|
+
el = utils_dom.querySelectorVisible(this.elPopup, ":read-write, select:not(:disabled)");
|
|
454
|
+
}
|
|
455
|
+
if (!el) {
|
|
456
|
+
el = utils_dom.querySelectorVisible(this.elPopup, ".top-popup_footer .top-button");
|
|
457
|
+
}
|
|
458
|
+
if (!el) {
|
|
459
|
+
el = this.elPopup;
|
|
460
|
+
}
|
|
461
|
+
el.focus();
|
|
462
|
+
}
|
|
463
|
+
mountEvents() {
|
|
464
|
+
this.addEventListenerWithUnmount(document, "mousedown", (e) => this.onMousedown(e));
|
|
465
|
+
this.addEventListenerWithUnmount(this.elPopup, "focus", (e) => this.onFocus(e));
|
|
466
|
+
if (this.options.openByHover) {
|
|
467
|
+
this.addEventListenerWithUnmount(this.elPopup, "mouseleave", (e) => this.onMouseleave(e));
|
|
468
|
+
this.addEventListenerWithUnmount(this.elPopupInner, "mouseleave", (e) => this.onMouseleave(e));
|
|
469
|
+
}
|
|
470
|
+
if (this.options.isFullScreen) {
|
|
471
|
+
this.addEventListenerWithUnmount(this.elPopupBody, "touchmove", (e) => this.onTouchmove(e));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Обработка клика вне окна
|
|
476
|
+
* @param {Event} e
|
|
477
|
+
*/
|
|
478
|
+
onMousedown(e) {
|
|
479
|
+
if (!this.elPopup) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (!this.isFirstClick) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
this.isFirstClick = false;
|
|
486
|
+
setTimeout(() => this.isFirstClick = true);
|
|
487
|
+
if (e.button !== 0) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
let elPopupOpened = utils_dom.querySelectorVisibleLast(document.body, ":scope > .top-popup-wrapper");
|
|
491
|
+
if (elPopupOpened && elPopupOpened !== this.elPopup) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
elPopupOpened = utils_dom.querySelectorVisibleLast(e.target.closest(".top-popup-front"), ":scope > .top-popup-wrapper");
|
|
495
|
+
if (elPopupOpened && elPopupOpened !== this.elPopup) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (this.elPopup.contains(e.target)) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (this.elPopup.closest(".ui-dialog") && !e.target.closest(".ui-dialog")) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (popup_worker.decoratorIsIgnoreOuterClick(e)) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
popup_worker.close(this.elPopup);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Закрыть другие Popup при фокусе на элемент формы в текущем
|
|
511
|
+
* @param {Event} e
|
|
512
|
+
*/
|
|
513
|
+
onFocus(e) {
|
|
514
|
+
if (e.target.matches("input")) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (this.isClosed) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const elsPopups = popup_worker.getAllVisible();
|
|
521
|
+
elsPopups.forEach((elPopup) => {
|
|
522
|
+
var _a, _b, _c;
|
|
523
|
+
if (this.elPopup.contains(elPopup)) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (((_a = this.popupParent) == null ? void 0 : _a.elPopup) === elPopup || ((_c = (_b = this.popupParent) == null ? void 0 : _b.popupParent) == null ? void 0 : _c.elPopup) === elPopup) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
popup_worker.close(elPopup);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Закрыть Popup при отведении мыши
|
|
534
|
+
* @param {Event} _e
|
|
535
|
+
*/
|
|
536
|
+
onMouseleave(_e) {
|
|
537
|
+
setTimeout(() => {
|
|
538
|
+
if (this.elPopupInner.matches(":hover")) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
popup_worker.close(this.elPopup);
|
|
542
|
+
}, 100);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Контроль положения Popup при fixed позиционировании
|
|
546
|
+
*/
|
|
547
|
+
onResize() {
|
|
548
|
+
if (this.elPopup.parentElement !== document.body) {
|
|
549
|
+
document.body.append(this.elPopup);
|
|
550
|
+
}
|
|
551
|
+
this.elPopup.style.top = utils_dom.offset(this.el).top + "px";
|
|
552
|
+
this.elPopup.style.left = utils_dom.offset(this.el).left + "px";
|
|
553
|
+
}
|
|
554
|
+
unmount() {
|
|
555
|
+
super.unmount();
|
|
556
|
+
this.el.dataset.topPopupOpened = "";
|
|
557
|
+
if (!this.elActiveByDefault) {
|
|
558
|
+
this.el.classList.remove("top-active");
|
|
559
|
+
}
|
|
560
|
+
let style = this.el.getAttribute("style");
|
|
561
|
+
if (style) {
|
|
562
|
+
style = style.replace(/position:[^;]*;?/g, "");
|
|
563
|
+
this.el.setAttribute("style", style);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
// контроль за положением Popup, чтобы оно не вылезало за пределы документа
|
|
567
|
+
recalcPosition() {
|
|
568
|
+
let p = this.options.p;
|
|
569
|
+
let leftPos;
|
|
570
|
+
this.elPopup.style.height = this.el.offsetHeight + "px";
|
|
571
|
+
this.elPopup.classList.remove("p0", "p1", "p2", "p3", "p4");
|
|
572
|
+
this.elPopup.classList.add("p" + p);
|
|
573
|
+
switch (this.options.posBy) {
|
|
574
|
+
case "left":
|
|
575
|
+
leftPos = this.el.offsetLeft + parseInt(this.el.style["margin-left"] || 0);
|
|
576
|
+
leftPos += this.shift.left;
|
|
577
|
+
this.elPopup.style.left = leftPos + "px";
|
|
578
|
+
break;
|
|
579
|
+
case "right":
|
|
580
|
+
leftPos = this.el.offsetLeft + parseInt(this.el.style["margin-left"] || 0);
|
|
581
|
+
this.elPopup.style.right = this.el.offsetParent.offsetWidth - this.el.offsetWidth - leftPos + "px";
|
|
582
|
+
break;
|
|
583
|
+
case "fixed":
|
|
584
|
+
this.addEventListenerWithUnmount(window, "resize", () => this.onResize());
|
|
585
|
+
this.onResize();
|
|
586
|
+
break;
|
|
587
|
+
default:
|
|
588
|
+
this.options.posBy.append(this.elPopup);
|
|
589
|
+
}
|
|
590
|
+
const boundingClientRect = this.elPopup.getBoundingClientRect();
|
|
591
|
+
this.elPopup.style.setProperty("--top-popup-height", this.elPopup.offsetHeight + "px");
|
|
592
|
+
this.elPopup.style.setProperty("--top-popup-right-bounding", boundingClientRect.right + "px");
|
|
593
|
+
this.elPopup.style.setProperty("--top-popup-bottom-bounding", boundingClientRect.bottom + "px");
|
|
594
|
+
this.elPopup.style.setProperty("--top-popup-top", boundingClientRect.top + "px");
|
|
595
|
+
this.elPopup.style.setProperty("--top-popup-left", boundingClientRect.left + "px");
|
|
596
|
+
this.elPopupInner.style.maxWidth = "unset";
|
|
597
|
+
this.elPopupInner.style.maxHeight = "unset";
|
|
598
|
+
let outTop = false;
|
|
599
|
+
let outRight = false;
|
|
600
|
+
let outBottom = false;
|
|
601
|
+
let outLeft = false;
|
|
602
|
+
let usefulInvertX = boundingClientRect.left > window.innerWidth / 2;
|
|
603
|
+
let usefulInvertY = boundingClientRect.top > window.innerHeight / 2;
|
|
604
|
+
if (p === 4) {
|
|
605
|
+
usefulInvertX = !usefulInvertX;
|
|
606
|
+
}
|
|
607
|
+
if (p === 1) {
|
|
608
|
+
usefulInvertY = !usefulInvertY;
|
|
609
|
+
}
|
|
610
|
+
const contentBoundingClientRect = this.elPopupInner.getBoundingClientRect();
|
|
611
|
+
const contentRight = window.innerWidth - contentBoundingClientRect.right;
|
|
612
|
+
const contentBottom = window.innerHeight - contentBoundingClientRect.bottom;
|
|
613
|
+
const margin = 8;
|
|
614
|
+
if (contentBoundingClientRect.top < margin) {
|
|
615
|
+
outTop = true;
|
|
616
|
+
}
|
|
617
|
+
if (contentRight < margin) {
|
|
618
|
+
outRight = true;
|
|
619
|
+
}
|
|
620
|
+
if (contentBottom < margin) {
|
|
621
|
+
outBottom = true;
|
|
622
|
+
}
|
|
623
|
+
if (contentBoundingClientRect.left < margin) {
|
|
624
|
+
outLeft = true;
|
|
625
|
+
}
|
|
626
|
+
if (outTop && (p === 0 || p === 1) && usefulInvertY) {
|
|
627
|
+
p = 3;
|
|
628
|
+
}
|
|
629
|
+
if (outBottom && p === 3 && usefulInvertY) {
|
|
630
|
+
p = 1;
|
|
631
|
+
}
|
|
632
|
+
if (outRight && p === 2 && usefulInvertX) {
|
|
633
|
+
p = 4;
|
|
634
|
+
}
|
|
635
|
+
if (outLeft && p === 4 && usefulInvertX) {
|
|
636
|
+
p = 2;
|
|
637
|
+
}
|
|
638
|
+
if (outRight && (p === 0 || p === 1 || p === 3)) {
|
|
639
|
+
this.elPopup.classList.add("invert-x");
|
|
640
|
+
}
|
|
641
|
+
if (outBottom && (p === 2 || p === 4) && usefulInvertY) {
|
|
642
|
+
if (p === 2 && !usefulInvertX) {
|
|
643
|
+
this.elPopup.classList.add("invert-y");
|
|
644
|
+
}
|
|
645
|
+
if (p === 4 && !usefulInvertX) {
|
|
646
|
+
this.elPopup.classList.add("invert-x");
|
|
647
|
+
}
|
|
648
|
+
if (!this.elPopup.matches(".invert-y")) {
|
|
649
|
+
p = 1;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
this.elPopup.classList.remove("p0", "p1", "p2", "p3", "p4");
|
|
653
|
+
this.elPopup.classList.add("p" + p);
|
|
654
|
+
this.elPopupInner.style.maxWidth = "";
|
|
655
|
+
this.elPopupInner.style.maxHeight = "";
|
|
656
|
+
popup_worker.scrollToActive(this.elPopup);
|
|
657
|
+
}
|
|
658
|
+
onTouchmove(e) {
|
|
659
|
+
let hasScrollX = e.currentTarget.scrollWidth > e.currentTarget.offsetWidth;
|
|
660
|
+
if (hasScrollX) {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
let hasScrollX2 = e.target.parentElement.scrollWidth > e.target.parentElement.offsetWidth;
|
|
664
|
+
if (hasScrollX2) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
if (!e.currentTarget.matches(".has_scroll")) {
|
|
668
|
+
e.preventDefault();
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
close() {
|
|
672
|
+
if (this.isClosed) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
this.isClosed = true;
|
|
676
|
+
if (this.$) {
|
|
677
|
+
this.$.trigger("afterclose.top-menu-popup", [jQuery(this.elPopup)]);
|
|
678
|
+
}
|
|
679
|
+
if (popup_worker.noClose) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
this.unmount();
|
|
683
|
+
this.elPopup.classList.add("top-popup-wrapper-closed");
|
|
684
|
+
setTimeout(() => {
|
|
685
|
+
var _a, _b, _c;
|
|
686
|
+
this.vueClose();
|
|
687
|
+
if (this.options.useOriginal) {
|
|
688
|
+
this.elPopup.removeAttribute("style");
|
|
689
|
+
this.elPopup.classList.remove("top-popup-wrapper-shown", "top-popup-wrapper-closed");
|
|
690
|
+
this.elPopup.classList.add("template");
|
|
691
|
+
this.elStartPosition.append(this.elPopup);
|
|
692
|
+
(_a = this.elPopup.querySelector("div.top-popup_content.top-column")) == null ? void 0 : _a.classList.remove("top-column");
|
|
693
|
+
(_b = this.elPopup.querySelector(".notch-border")) == null ? void 0 : _b.remove();
|
|
694
|
+
(_c = this.elPopup.querySelector(".notch")) == null ? void 0 : _c.remove();
|
|
695
|
+
this.elPopupInner.replaceWith(...this.elPopupInner.childNodes);
|
|
696
|
+
utils_dom.storageClear(this.elPopup);
|
|
697
|
+
} else {
|
|
698
|
+
utils_dom.storageClear(this.elPopup);
|
|
699
|
+
this.elPopup.remove();
|
|
700
|
+
delete this.elPopup;
|
|
701
|
+
}
|
|
702
|
+
const elsPopups = popup_worker.getAllVisible();
|
|
703
|
+
const elPopupLast = elsPopups.length && elsPopups[elsPopups.length - 1];
|
|
704
|
+
if (elPopupLast) {
|
|
705
|
+
popup_worker.getPopup(elPopupLast).focus();
|
|
706
|
+
} else {
|
|
707
|
+
document.documentElement.classList.remove("with_popup");
|
|
708
|
+
}
|
|
709
|
+
}, 300);
|
|
710
|
+
}
|
|
711
|
+
async vueOpen() {
|
|
712
|
+
var _a;
|
|
713
|
+
await ((_a = this.vueGetComponent()) == null ? void 0 : _a.onOpen(this));
|
|
714
|
+
}
|
|
715
|
+
vueClose() {
|
|
716
|
+
var _a;
|
|
717
|
+
(_a = this.vueGetComponent()) == null ? void 0 : _a.onClose(this);
|
|
718
|
+
}
|
|
719
|
+
// получить vueConnectors компонента Popup
|
|
720
|
+
vueGetComponent() {
|
|
721
|
+
return popup_worker.vueConnectors.get(this.el.dataset.topPopupId);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
GlobalEvents.init();
|
|
725
|
+
exports.default = Popup;
|
|
726
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
727
|
+
});
|
|
728
|
+
//# sourceMappingURL=popup-8f650530.amd.js.map
|