PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / views / public / Dialog / DialogForms.vue
ameliabooking / v3 / src / views / public / Dialog Last commit date
DialogForms.vue 5 days ago
DialogForms.vue
298 lines
1 <script setup>
2 import AmDialog from '../../_components/dialog/AmDialog.vue'
3
4 import SbsForm from '../StepForm/BookingStepForm.vue'
5 import CbfForm from '../CatalogForm/CatalogForm.vue'
6 import ElfForm from '../EventForm/EventListForm/EventsListForm.vue'
7 import EcfForm from '../EventForm/EventCalendarForm/EvensCalendarForm.vue'
8
9 // * Import from Vue
10 import { markRaw, reactive, ref, inject, computed, onMounted, watchEffect, provide } from 'vue'
11
12 // * Import composables
13 import { defaultCustomizeSettings } from '../../../assets/js/common/defaultCustomize'
14 import { useRenderAction } from '../../../assets/js/public/renderActions'
15
16 // * Shortcode Data
17 let shortcodeData = inject('shortcodeData')
18
19 // * List of forms
20 let formList = reactive({
21 sbsNew: markRaw(SbsForm),
22 cbf: markRaw(CbfForm),
23 elf: markRaw(ElfForm),
24 ecf: markRaw(EcfForm),
25 })
26
27 let dialogWrapperWidth = ref(0)
28 provide('dialogWrapperWidth', dialogWrapperWidth)
29
30 let dialogVisibility = ref(false)
31 provide('formDialogVisibility', dialogVisibility)
32
33 let isRestored = computed(() =>
34 'isRestored' in shortcodeData.value ? shortcodeData.value.isRestored : false,
35 )
36
37 let externalButtons =
38 shortcodeData.value.trigger_type && shortcodeData.value.trigger_type === 'class'
39 ? [...document.getElementsByClassName(shortcodeData.value.trigger)]
40 : [document.getElementById(shortcodeData.value.trigger)]
41
42 let resizeAfter = ref(100)
43
44 let loadDialogCounter = ref(0)
45 provide('loadDialogCounter', loadDialogCounter)
46
47 externalButtons.forEach((btn) => {
48 btn.addEventListener('click', (a) => {
49 a.preventDefault()
50 a.stopPropagation()
51 dialogVisibility.value = true
52
53 if (!isRestored.value) {
54 loadDialogCounter.value++
55 }
56
57 setTimeout(() => {
58 window.dispatchEvent(new Event('resize'))
59 }, resizeAfter.value)
60 })
61 })
62
63 watchEffect(() => {
64 if (isRestored.value) {
65 externalButtons.forEach((btn) => {
66 btn.dispatchEvent(new Event('click'))
67 })
68 }
69 })
70
71 function resetDialogState() {
72 dialogVisibility.value = false
73 }
74
75 let dynamicVh = ref(0)
76 function updateVH() {
77 dynamicVh.value = window.visualViewport.height
78 }
79
80 window.addEventListener('resize', updateVH)
81
82 // * Global flag for determination when component is fully loaded (used for Amelia popup)
83 let isMounted = inject('isMounted')
84
85 onMounted(() => {
86 isMounted.value = true
87
88 useRenderAction('renderPopup', {
89 resizeAfter,
90 })
91
92 updateVH()
93 })
94
95 // * Root Settings
96 const amSettings = inject('settings')
97
98 // * Colors block
99 let amColors = computed(() => {
100 return amSettings.customizedData &&
101 shortcodeData.value.triggered_form in amSettings.customizedData
102 ? amSettings.customizedData[shortcodeData.value.triggered_form].colors
103 : defaultCustomizeSettings[shortcodeData.value.triggered_form].colors
104 })
105
106 let formData = computed(() => {
107 return amSettings.customizedData &&
108 shortcodeData.value.triggered_form in amSettings.customizedData
109 ? amSettings.customizedData[shortcodeData.value.triggered_form]
110 : defaultCustomizeSettings[shortcodeData.value.triggered_form]
111 })
112
113 let cssVars = computed(() => {
114 return {
115 '--am-c-primary': amColors.value.colorPrimary,
116 '--am-c-success': amColors.value.colorSuccess,
117 '--am-c-error': amColors.value.colorError,
118 '--am-c-warning': amColors.value.colorWarning,
119 '--am-c-main-bgr': amColors.value.colorMainBgr,
120 '--am-c-main-heading-text': amColors.value.colorMainHeadingText,
121 '--am-c-main-text': amColors.value.colorMainText,
122 '--am-dvh': dynamicVh.value ? `${dynamicVh.value}px` : '100dvh',
123 }
124 })
125
126 watchEffect(
127 () => {
128 if (shortcodeData.value.triggered_form === 'sbsNew') {
129 dialogWrapperWidth.value = formData.value.sidebar.options.self.visibility ? '760px' : '520px'
130 }
131
132 if (shortcodeData.value.triggered_form === 'cbf') {
133 dialogWrapperWidth.value = '1140px'
134 }
135
136 if (shortcodeData.value.triggered_form === 'elf') {
137 dialogWrapperWidth.value = '792px'
138 }
139 },
140 { flush: 'post' },
141 )
142 </script>
143
144 <script>
145 export default {
146 name: 'AmeliaDialogForms',
147 }
148 </script>
149
150 <template>
151 <AmDialog
152 v-model="dialogVisibility"
153 :append-to-body="true"
154 :modal-class="`amelia-v2-booking am-forms-dialog am-${shortcodeData.triggered_form}`"
155 :close-on-click-modal="false"
156 :close-on-press-escape="false"
157 :custom-styles="cssVars"
158 :used-for-shortcode="true"
159 :width="dialogWrapperWidth"
160 @closed="resetDialogState"
161 >
162 <component :is="formList[shortcodeData.triggered_form]"></component>
163 </AmDialog>
164 </template>
165
166 <style lang="scss">
167 .amelia-v2-booking {
168 &.am-forms-dialog {
169 background-color: rgba(0, 0, 0, 0.5);
170 z-index: 9999999 !important;
171
172 &.am-cbf {
173 .el-dialog {
174 margin-top: 32px;
175 &__headerbtn {
176 top: -32px;
177 right: 0;
178 width: 22px;
179 height: 22px;
180 display: flex;
181 background-color: var(--am-c-main-bgr);
182 border-radius: 50%;
183 align-items: center;
184 justify-content: center;
185
186 &:active {
187 position: absolute;
188 border: none;
189 outline: 0;
190 }
191 }
192 }
193 }
194
195 .el-dialog {
196 box-shadow: none;
197 border-radius: 8px;
198 background-color: transparent;
199
200 @media only screen and (max-width: 768px) {
201 margin-top: 0;
202 width: 100%;
203 max-width: 100%;
204
205 #amelia-container {
206 &.am-fs {
207 &__wrapper {
208 max-height: unset;
209 height: var(--am-dvh, 100vh);
210 }
211 }
212
213 .am-fs {
214 &-sb {
215 &__step-wrapper {
216 height: calc(var(--am-dvh, 100vh) - 182px);
217 }
218 }
219
220 &__main-content {
221 height: calc(var(--am-dvh, 100vh) - 118px);
222 }
223 }
224
225 .am-els {
226 &__wrapper {
227 overflow-x: hidden;
228 height: calc(var(--am-dvh, 100vh) - 230px);
229
230 &::-webkit-scrollbar {
231 width: 6px;
232 }
233
234 &::-webkit-scrollbar-thumb {
235 border-radius: 6px;
236 background: var(--am-c-scroll-op30);
237 }
238
239 &::-webkit-scrollbar-track {
240 border-radius: 6px;
241 background: var(--am-c-scroll-op10);
242 }
243 }
244 }
245 }
246 }
247
248 .el-dialog__header {
249 padding: 0;
250 }
251
252 &__headerbtn {
253 z-index: 10;
254 top: 16px;
255 right: 16px;
256
257 &:active {
258 position: absolute;
259 border: none;
260 outline: 0;
261 background-color: initial;
262 }
263
264 &:hover {
265 border: none;
266 }
267
268 .el-dialog__close {
269 color: var(--am-c-main-text);
270 }
271 }
272
273 .el-dialog__body {
274 padding: 0;
275 }
276
277 &__footer {
278 display: none;
279 }
280 }
281
282 #amelia-container {
283 * {
284 font-family: var(--am-font-family), sans-serif;
285 box-sizing: border-box;
286 word-break: break-word;
287 }
288
289 &.am-fs {
290 &__wrapper {
291 margin: 0;
292 }
293 }
294 }
295 }
296 }
297 </style>
298