CustomizeCatalog.vue
4 weeks ago
CustomizeCustomerPanel.vue
4 weeks ago
CustomizeEmployeePanel.vue
1 month ago
CustomizeEventCalendar.vue
1 month ago
CustomizeEventList.vue
1 month ago
CustomizeStepNew.vue
4 weeks ago
CustomizeStepNew.vue
857 lines
| 1 | <template> |
| 2 | <div |
| 3 | v-if="isLoaded" |
| 4 | id="amelia-container" |
| 5 | ref="ameliaContainer" |
| 6 | class="am-fs__wrapper" |
| 7 | :class="{ 'am-collapsed': sidebarCollapsed }" |
| 8 | :style="cssVars" |
| 9 | > |
| 10 | <SideBar |
| 11 | v-if="sidebarVisibility && containerWidth > 560" |
| 12 | class="am-fs-sb" |
| 13 | :class="{ 'am-collapsed': sidebarCollapsed }" |
| 14 | :style="{ |
| 15 | width: !sidebarCollapsed ? '240px' : '72px', |
| 16 | paddingBottom: `${sidebarFooterHeight + 16}px`, |
| 17 | }" |
| 18 | > |
| 19 | <template #step-list> |
| 20 | <div class="am-fs-sb__step-wrapper" tabindex="0"> |
| 21 | <template v-if="stepsArray[stepIndex] !== congratulationsStep"> |
| 22 | <div v-for="step in sidebarSteps" :key="step.label" class="am-fs-sb__step"> |
| 23 | <div class="am-fs-sb__step-inner"> |
| 24 | <div class="am-fs-sb__step-icon"> |
| 25 | <span :class="`am-icon-${step.icon}`"></span> |
| 26 | <span |
| 27 | v-if="step.key === 'cartStep'" |
| 28 | class="am-fs-sb__step-icon__number" |
| 29 | :class="sidebarCollapseItemsClass" |
| 30 | > |
| 31 | 3 |
| 32 | </span> |
| 33 | </div> |
| 34 | <transition name="fade"> |
| 35 | <p |
| 36 | v-if="!sidebarCollapsed" |
| 37 | class="am-fs-sb__step-heading" |
| 38 | :class="sidebarCollapseItemsClass" |
| 39 | > |
| 40 | {{ step.label }} |
| 41 | </p> |
| 42 | </transition> |
| 43 | <div |
| 44 | class="am-fs-sb__step-checker" |
| 45 | :class="[ |
| 46 | { 'am-fs-sb__step-checker-selected': step.selected }, |
| 47 | sidebarCollapseItemsClass, |
| 48 | ]" |
| 49 | > |
| 50 | <transition name="fade"> |
| 51 | <span v-if="step.finished" class="am-icon-check"></span> |
| 52 | </transition> |
| 53 | </div> |
| 54 | </div> |
| 55 | <TransitionGroup |
| 56 | tag="span" |
| 57 | name="fade" |
| 58 | appear |
| 59 | class="am-fs-sb__step-selection__wrapper" |
| 60 | :class="{ |
| 61 | 'am-fs-sb__step-selection-packages': |
| 62 | step.key === packageAppointmentsStep.key && step.stepSelectedData.length > 3, |
| 63 | }" |
| 64 | > |
| 65 | <p |
| 66 | v-for="(itemSelected, index) in step.stepSelectedData" |
| 67 | :key="itemSelected.position" |
| 68 | class="am-fs-sb__step-selection" |
| 69 | > |
| 70 | <span v-if="step.key !== packageAppointmentsStep.key || index < 3"> |
| 71 | {{ itemSelected.value }} |
| 72 | </span> |
| 73 | <span v-else> |
| 74 | {{ labelsDisplay('plus_more', 'sidebar') }} |
| 75 | </span> |
| 76 | </p> |
| 77 | </TransitionGroup> |
| 78 | </div> |
| 79 | </template> |
| 80 | <template v-else> |
| 81 | <div> |
| 82 | <transition name="fade"> |
| 83 | <AddToCalendar |
| 84 | v-if="!sidebarCollapsed" |
| 85 | :use-in-sb="true" |
| 86 | :calendar-string="labelsDisplay('add_to_calendar', 'congratulations')" |
| 87 | ></AddToCalendar> |
| 88 | </transition> |
| 89 | <div v-if="sidebarCollapsed" class="am-fs-sb__step"> |
| 90 | <div class="am-fs-sb__step-inner"> |
| 91 | <div class="am-fs-sb__step-icon"> |
| 92 | <span class="am-icon-pennant"></span> |
| 93 | </div> |
| 94 | <div |
| 95 | class="am-fs-sb__step-checker am-fs-sb__step-checker-selected" |
| 96 | :class="sidebarCollapseItemsClass" |
| 97 | > |
| 98 | <transition name="fade"> |
| 99 | <span class="am-icon-check"></span> |
| 100 | </transition> |
| 101 | </div> |
| 102 | </div> |
| 103 | </div> |
| 104 | </div> |
| 105 | </template> |
| 106 | </div> |
| 107 | </template> |
| 108 | <template #support-info> |
| 109 | <div ref="sidebarFooterRef" class="am-fs-sb__footer"> |
| 110 | <div |
| 111 | v-if=" |
| 112 | amCustomize[pageRenderKey].sidebar.options.supportHeading.visibility || |
| 113 | amCustomize[pageRenderKey].sidebar.options.companyPhone.visibility || |
| 114 | amCustomize[pageRenderKey].sidebar.options.companyEmail.visibility |
| 115 | " |
| 116 | class="am-fs-sb__support" |
| 117 | > |
| 118 | <transition name="fade"> |
| 119 | <div |
| 120 | v-if=" |
| 121 | !sidebarCollapsed && |
| 122 | amCustomize[pageRenderKey].sidebar.options.supportHeading.visibility |
| 123 | " |
| 124 | class="am-fs-sb__support-heading" |
| 125 | :class="sidebarCollapseItemsClass" |
| 126 | > |
| 127 | {{ labelsDisplay('get_in_touch', 'sidebar') }} |
| 128 | </div> |
| 129 | </transition> |
| 130 | <div |
| 131 | v-if="amCustomize[pageRenderKey].sidebar.options.companyPhone.visibility" |
| 132 | class="am-fs-sb__support-email" |
| 133 | > |
| 134 | <template v-if="!sidebarCollapsed"> +111222333 </template> |
| 135 | <template v-else> |
| 136 | <span class="am-icon-phone"></span> |
| 137 | </template> |
| 138 | </div> |
| 139 | <div |
| 140 | v-if="amCustomize[pageRenderKey].sidebar.options.companyEmail.visibility" |
| 141 | class="am-fs-sb__support-email" |
| 142 | > |
| 143 | <template v-if="!sidebarCollapsed"> support@wpamelia.com </template> |
| 144 | <template v-else> |
| 145 | <span class="am-icon-email"></span> |
| 146 | </template> |
| 147 | </div> |
| 148 | </div> |
| 149 | <div |
| 150 | class="am-fs-sb__menu" |
| 151 | :class="sidebarCollapseItemsClass" |
| 152 | @click="sidebarCollapsed = !sidebarCollapsed" |
| 153 | > |
| 154 | <Transition name="fade"> |
| 155 | <span v-if="!sidebarCollapsed" class="am-fs-sb__menu-text"> |
| 156 | {{ labelsDisplay('collapse_menu', 'sidebar') }} |
| 157 | </span> |
| 158 | </Transition> |
| 159 | <span :class="`am-icon-arrow-circle-${sidebarCollapsed ? 'left' : 'right'}`"></span> |
| 160 | </div> |
| 161 | </div> |
| 162 | </template> |
| 163 | </SideBar> |
| 164 | <MainContent class="am-fs__main"> |
| 165 | <template v-if="stepsArray[stepIndex] !== congratulationsStep" #header> |
| 166 | <MainContentHeader |
| 167 | :sidebar-visible="amCustomize.sbsNew.sidebar.options.self.visibility" |
| 168 | ></MainContentHeader> |
| 169 | </template> |
| 170 | <template #step> |
| 171 | <component :is="stepsArray[stepIndex]" class="am-fs__main-content"></component> |
| 172 | </template> |
| 173 | <template #footer> |
| 174 | <MainContentFooter |
| 175 | :customized-labels="globalStepLabels()" |
| 176 | :primary-footer-button-type=" |
| 177 | amCustomize[pageRenderKey][stepName].options.primaryFooterButton.buttonType |
| 178 | " |
| 179 | :secondary-footer-button-type="footerButtonType" |
| 180 | :second-button-show=" |
| 181 | !licence.isLite ? stepsArray[stepIndex] === congratulationsStep : false |
| 182 | " |
| 183 | :add-to-cart-button-show="stepsArray[stepIndex] === cartStep" |
| 184 | :add-to-cart-button-type=" |
| 185 | amCustomize[pageRenderKey].cartStep.options.addToCart.buttonType |
| 186 | " |
| 187 | :back-to-cart-button-show=" |
| 188 | !licence.isLite && !licence.isStarter && !licence.isBasic |
| 189 | ? stepsArray.indexOf(cartStep) > stepIndex |
| 190 | : false |
| 191 | " |
| 192 | :back-to-cart-button-type=" |
| 193 | amCustomize[pageRenderKey].cartStep.options.backToCart.buttonType |
| 194 | " |
| 195 | :back-to-cart-label="dedicatedStepLabel('cancel', 'cartStep')" |
| 196 | ></MainContentFooter> |
| 197 | </template> |
| 198 | </MainContent> |
| 199 | </div> |
| 200 | </template> |
| 201 | |
| 202 | <script setup> |
| 203 | // * Form construction |
| 204 | import SideBar from '../../../common/SbsFormConstruction/SideBar/SideBar.vue' |
| 205 | import MainContent from '../../../common/SbsFormConstruction/MainContent/MainContent.vue' |
| 206 | import MainContentHeader from '../../../common/SbsFormConstruction/MainContent/parts/MainContentHeader.vue' |
| 207 | import MainContentFooter from '../../../common/SbsFormConstruction/MainContent/parts/MainContentFooter.vue' |
| 208 | |
| 209 | // * Parts |
| 210 | import AddToCalendar from '../steps/parts/AddToCalendar.vue' |
| 211 | |
| 212 | // * Step components |
| 213 | import InitStep from '../steps/StepForm/InitStep.vue' |
| 214 | import ServiceStep from '../steps/StepForm/ServiceStep.vue' |
| 215 | import EmployeeStep from '../steps/StepForm/EmployeeStep.vue' |
| 216 | import LocationStep from '../steps/StepForm/LocationStep.vue' |
| 217 | import Extras from '../steps/StepForm/Extras.vue' |
| 218 | import DateTimeStep from '../steps/StepForm/DateTimeStep.vue' |
| 219 | import CartStep from '../steps/StepForm/CartStep.vue' |
| 220 | import RecurringStep from '../steps/StepForm/RecurringStep.vue' |
| 221 | import RecurringSummary from '../steps/StepForm/RecurringSummary.vue' |
| 222 | import InfoStep from '../steps/StepForm/InfoStep.vue' |
| 223 | import PaymentStep from '../steps/StepForm/PaymentStep.vue' |
| 224 | import Congratulations from '../steps/StepForm/Congratulations.vue' |
| 225 | import PackageStep from '../steps/StepForm/PackageStep.vue' |
| 226 | import PackageInfoStep from '../steps/StepForm/PackageInfoStep.vue' |
| 227 | import PackageAppointmentsStep from '../steps/StepForm/PackageAppointmentsStep.vue' |
| 228 | import PackageAppointmentsListStep from '../steps/StepForm/PackageAppointmentsListStep.vue' |
| 229 | |
| 230 | // * Import from Vue |
| 231 | import { |
| 232 | ref, |
| 233 | provide, |
| 234 | inject, |
| 235 | markRaw, |
| 236 | watch, |
| 237 | watchEffect, |
| 238 | computed, |
| 239 | onBeforeMount, |
| 240 | onMounted, |
| 241 | onUnmounted, |
| 242 | nextTick, |
| 243 | } from 'vue' |
| 244 | |
| 245 | import { useElementSize } from '@vueuse/core' |
| 246 | |
| 247 | // * Import composables |
| 248 | import { defaultCustomizeSettings } from '../../../../assets/js/common/defaultCustomize.js' |
| 249 | import { useReactiveCustomize } from '../../../../assets/js/admin/useReactiveCustomize.js' |
| 250 | |
| 251 | let loading = ref(false) |
| 252 | provide('loading', loading) |
| 253 | |
| 254 | // * Plugin Licence |
| 255 | let licence = inject('licence') |
| 256 | |
| 257 | // * Base Urls |
| 258 | const baseUrls = inject('baseUrls') |
| 259 | |
| 260 | // * Layout |
| 261 | let flowLayout = useReactiveCustomize().flowLayout |
| 262 | |
| 263 | // * Bookable Type |
| 264 | let bookableType = useReactiveCustomize().bookableType |
| 265 | provide('bookableType', bookableType) |
| 266 | |
| 267 | // * Global Labels |
| 268 | const amLabels = inject('labels') |
| 269 | |
| 270 | // * Features integrations |
| 271 | let features = useReactiveCustomize().features |
| 272 | provide('features', features) |
| 273 | |
| 274 | // * Selected Language |
| 275 | let langKey = useReactiveCustomize().langKey |
| 276 | provide('langKey', langKey) |
| 277 | |
| 278 | // * Step index |
| 279 | let { stepIndex } = useReactiveCustomize() |
| 280 | provide('stepIndex', stepIndex) |
| 281 | |
| 282 | // * Page Render Key |
| 283 | let pageRenderKey = ref('sbsNew') |
| 284 | provide('pageRenderKey', pageRenderKey) |
| 285 | |
| 286 | // * Step Name |
| 287 | let { stepName } = useReactiveCustomize() |
| 288 | provide('stepName', stepName) |
| 289 | |
| 290 | let subStepName = useReactiveCustomize().subStepName |
| 291 | provide('subStepName', subStepName) |
| 292 | |
| 293 | // Use the reactive customize composable |
| 294 | const { amCustomize } = useReactiveCustomize() |
| 295 | provide('customize', amCustomize) |
| 296 | |
| 297 | let amFonts = computed(() => { |
| 298 | return amCustomize.value.fonts |
| 299 | }) |
| 300 | provide('amFonts', amFonts) |
| 301 | |
| 302 | let isLoaded = ref(false) |
| 303 | |
| 304 | onMounted(() => { |
| 305 | window.customizeComponentLoaded = true |
| 306 | |
| 307 | if (typeof window.stylesInjectedV3 === 'function') { |
| 308 | if (window.v3.componentToMount === 'CustomizeStepNew') { |
| 309 | window.stylesInjectedV3 = () => { |
| 310 | nextTick().then(() => { |
| 311 | isLoaded.value = true |
| 312 | }) |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | }) |
| 317 | |
| 318 | onUnmounted(() => { |
| 319 | window.customizeComponentLoaded = false |
| 320 | // Reset to no-op function |
| 321 | window.stylesInjectedV3 = async function () {} |
| 322 | }) |
| 323 | |
| 324 | // * Form Sidebar Collapse |
| 325 | let sidebarCollapsed = ref(false) |
| 326 | |
| 327 | let sidebarCollapseItemsClass = ref('') |
| 328 | |
| 329 | watch(sidebarCollapsed, (current) => { |
| 330 | if (current) { |
| 331 | setTimeout(() => { |
| 332 | sidebarCollapseItemsClass.value = 'am-collapsed' |
| 333 | }, 1000) |
| 334 | } else { |
| 335 | sidebarCollapseItemsClass.value = '' |
| 336 | } |
| 337 | }) |
| 338 | |
| 339 | let sidebarFooterRef = ref(null) |
| 340 | const { height: sideFooterHeight } = useElementSize(sidebarFooterRef) |
| 341 | |
| 342 | let sidebarFooterHeight = computed(() => { |
| 343 | return sideFooterHeight.value |
| 344 | }) |
| 345 | |
| 346 | const initStep = markRaw(InitStep) |
| 347 | const serviceStep = markRaw(ServiceStep) |
| 348 | const employeeStep = markRaw(EmployeeStep) |
| 349 | const locationStep = markRaw(LocationStep) |
| 350 | const extras = markRaw(Extras) |
| 351 | const dateTimeStep = markRaw(DateTimeStep) |
| 352 | const cartStep = markRaw(CartStep) |
| 353 | const recurringStep = markRaw(RecurringStep) |
| 354 | const recurringSummary = markRaw(RecurringSummary) |
| 355 | const infoStep = markRaw(InfoStep) |
| 356 | const paymentStep = markRaw(PaymentStep) |
| 357 | const congratulationsStep = markRaw(Congratulations) |
| 358 | const packageStep = markRaw(PackageStep) |
| 359 | const packageInfoStep = markRaw(PackageInfoStep) |
| 360 | const packageAppointmentsStep = markRaw(PackageAppointmentsStep) |
| 361 | const packageAppointmentsListStep = markRaw(PackageAppointmentsListStep) |
| 362 | |
| 363 | let footerButtonType = computed(() => { |
| 364 | return amCustomize.value[pageRenderKey.value][stepName.value].options.secondaryFooterButton |
| 365 | ? amCustomize.value[pageRenderKey.value][stepName.value].options.secondaryFooterButton |
| 366 | .buttonType |
| 367 | : 'text' |
| 368 | }) |
| 369 | |
| 370 | let stepOrder = computed(() => { |
| 371 | return amCustomize.value[pageRenderKey.value].order |
| 372 | }) |
| 373 | |
| 374 | let serviceFlow = computed(() => { |
| 375 | let values = [] |
| 376 | |
| 377 | if (flowLayout.value === 1) { |
| 378 | values.push(initStep) |
| 379 | } else { |
| 380 | stepOrder.value.forEach((item) => { |
| 381 | if (item.id === 'ServiceStep') values.push(serviceStep) |
| 382 | if ( |
| 383 | item.id === 'EmployeeStep' && |
| 384 | (licence.isStarter || licence.isBasic || licence.isPro || licence.isDeveloper) |
| 385 | ) |
| 386 | values.push(employeeStep) |
| 387 | if (item.id === 'LocationStep' && (licence.isBasic || licence.isPro || licence.isDeveloper)) |
| 388 | values.push(locationStep) |
| 389 | }) |
| 390 | } |
| 391 | |
| 392 | if (features.value.extras) { |
| 393 | values.push(extras) |
| 394 | } |
| 395 | |
| 396 | values.push(dateTimeStep) |
| 397 | |
| 398 | if (features.value.cart) { |
| 399 | values.push(cartStep) |
| 400 | } |
| 401 | |
| 402 | if (features.value.recurringAppointments) { |
| 403 | values.push(recurringStep) |
| 404 | |
| 405 | values.push(recurringSummary) |
| 406 | } |
| 407 | |
| 408 | values.push(infoStep) |
| 409 | |
| 410 | values.push(paymentStep) |
| 411 | |
| 412 | values.push(congratulationsStep) |
| 413 | |
| 414 | return values |
| 415 | }) |
| 416 | |
| 417 | let packageFlow = [ |
| 418 | packageStep, |
| 419 | packageInfoStep, |
| 420 | packageAppointmentsStep, |
| 421 | packageAppointmentsListStep, |
| 422 | infoStep, |
| 423 | paymentStep, |
| 424 | congratulationsStep, |
| 425 | ] |
| 426 | |
| 427 | let stepsArray = computed(() => { |
| 428 | if (bookableType.value === 'package') { |
| 429 | return packageFlow |
| 430 | } |
| 431 | |
| 432 | return serviceFlow.value |
| 433 | }) |
| 434 | |
| 435 | // * Array of Sidebar steps |
| 436 | const sidebarSteps = ref([]) |
| 437 | provide('sidebarSteps', sidebarSteps) |
| 438 | |
| 439 | // * Monitoring step index for step selection |
| 440 | watch(stepIndex, (currStepIndex) => { |
| 441 | if ( |
| 442 | 'key' in stepsArray.value[stepIndex.value] && |
| 443 | currStepIndex in sidebarSteps.value && |
| 444 | 'selected' in sidebarSteps.value[currStepIndex] && |
| 445 | 'finished' in sidebarSteps.value[currStepIndex] && |
| 446 | stepsArray.value[stepIndex.value].key !== 'congratulations' |
| 447 | ) { |
| 448 | sidebarSteps.value[currStepIndex].selected = true |
| 449 | sidebarSteps.value[currStepIndex].finished = true |
| 450 | } |
| 451 | }) |
| 452 | |
| 453 | /** |
| 454 | * Collecting and rearranging selected data in form sidebar based on item position in form |
| 455 | * @param data |
| 456 | */ |
| 457 | function sidebarDataCollector(data) { |
| 458 | // Determines are selected data already exists |
| 459 | if ( |
| 460 | sidebarSteps.value[stepIndex.value].stepSelectedData.filter( |
| 461 | (item) => item.reference === data.reference, |
| 462 | ).length |
| 463 | ) { |
| 464 | sidebarSteps.value[stepIndex.value].stepSelectedData.forEach((item, index, array) => { |
| 465 | // Handles changing value of existing data |
| 466 | if (item.reference === data.reference && data.value) { |
| 467 | item.value = data.value |
| 468 | } |
| 469 | |
| 470 | // Removes un-selected form data from sidebar array |
| 471 | if (item.reference === data.reference && !data.value) { |
| 472 | array.splice(index, 1) |
| 473 | } |
| 474 | }) |
| 475 | } else { |
| 476 | // Handles the selection of new data |
| 477 | sidebarSteps.value[stepIndex.value].stepSelectedData.push(data) |
| 478 | } |
| 479 | |
| 480 | // Rearranges data in sidebar based on item position in the form |
| 481 | sidebarSteps.value[stepIndex.value].stepSelectedData.sort((a, b) => { |
| 482 | return a.position - b.position |
| 483 | }) |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Function that creates Data Array for SideBar |
| 488 | */ |
| 489 | function sidebarDataCreator() { |
| 490 | stepsArray.value.forEach((item, index) => { |
| 491 | if ('key' in item && item.key !== 'congratulations') { |
| 492 | let stepLabels = amCustomize.value[pageRenderKey.value][item.key].translations |
| 493 | let labelKey = item.sidebarData.label |
| 494 | let heading = |
| 495 | stepLabels && stepLabels[labelKey] |
| 496 | ? stepLabels[labelKey][langKey.value] |
| 497 | : amLabels[labelKey] |
| 498 | |
| 499 | if (item.name !== 'CongratulationsStep') { |
| 500 | let step = { |
| 501 | key: item.key, |
| 502 | label: heading, |
| 503 | icon: item.sidebarData.icon, |
| 504 | labelKey: labelKey, |
| 505 | stepSelectedData: [], |
| 506 | finished: false, |
| 507 | selected: index === stepIndex.value, |
| 508 | } |
| 509 | sidebarSteps.value.splice(index, 0, step) |
| 510 | } |
| 511 | } |
| 512 | }) |
| 513 | } |
| 514 | |
| 515 | watch([bookableType, flowLayout, stepOrder], () => { |
| 516 | sidebarSteps.value = [] |
| 517 | sidebarDataCreator() |
| 518 | stepIndex.value = 0 |
| 519 | }) |
| 520 | |
| 521 | watchEffect(() => { |
| 522 | if (pageRenderKey.value === 'sbsNew') { |
| 523 | sidebarSteps.value.forEach((item) => { |
| 524 | if ( |
| 525 | amCustomize.value[pageRenderKey.value][item.key].translations && |
| 526 | amCustomize.value[pageRenderKey.value][item.key].translations[item.labelKey] && |
| 527 | amCustomize.value[pageRenderKey.value][item.key].translations[item.labelKey][langKey.value] |
| 528 | ) { |
| 529 | item.label = |
| 530 | amCustomize.value[pageRenderKey.value][item.key].translations[item.labelKey][ |
| 531 | langKey.value |
| 532 | ] |
| 533 | } else { |
| 534 | item.label = amLabels[item.labelKey] |
| 535 | } |
| 536 | }) |
| 537 | } |
| 538 | }) |
| 539 | |
| 540 | provide('sidebarStepsFunctions', { |
| 541 | sidebarDataCollector, |
| 542 | }) |
| 543 | |
| 544 | // * Component reference |
| 545 | let ameliaContainer = ref(null) |
| 546 | |
| 547 | // * Plugin wrapper width |
| 548 | let { width: containerWidth } = useElementSize(ameliaContainer) |
| 549 | provide('containerWidth', containerWidth) |
| 550 | |
| 551 | watchEffect(() => { |
| 552 | if (amCustomize.value.fonts.customFontSelected) { |
| 553 | activateCustomFontStyles() |
| 554 | } else { |
| 555 | importDefaultFonts() |
| 556 | } |
| 557 | }) |
| 558 | |
| 559 | function activateCustomFontStyles() { |
| 560 | let head = document.head || document.getElementsByTagName('head')[0] |
| 561 | if (head.querySelector('#amCustomFont')) { |
| 562 | head.querySelector('#amCustomFont').remove() |
| 563 | } |
| 564 | |
| 565 | if (head.querySelector('#amDefaultFontImport')) { |
| 566 | head.querySelector('#amDefaultFontImport').remove() |
| 567 | } |
| 568 | |
| 569 | let css = `@font-face {font-family: '${amCustomize.value.fonts.fontFamily}'; src: url(${amCustomize.value.fonts.fontUrl});}` |
| 570 | let style = document.createElement('style') |
| 571 | head.appendChild(style) |
| 572 | style.setAttribute('type', 'text/css') |
| 573 | style.setAttribute('id', 'amCustomFont') |
| 574 | style.appendChild(document.createTextNode(css)) |
| 575 | } |
| 576 | |
| 577 | function importDefaultFonts() { |
| 578 | const head = document.head || document.getElementsByTagName('head')[0] |
| 579 | if (head.querySelector('#amDefaultFontImport')) { |
| 580 | return |
| 581 | } |
| 582 | |
| 583 | const base = baseUrls.value.wpAmeliaPluginURL |
| 584 | const style = document.createElement('style') |
| 585 | style.setAttribute('type', 'text/css') |
| 586 | style.setAttribute('id', 'amDefaultFontImport') |
| 587 | style.textContent = `@import url("${base}v3/src/assets/scss/common/fonts/font.css");` |
| 588 | head.appendChild(style) |
| 589 | } |
| 590 | |
| 591 | let sidebarVisibility = computed(() => { |
| 592 | return amCustomize.value.sbsNew.sidebar.options.self.visibility |
| 593 | }) |
| 594 | |
| 595 | /** |
| 596 | * Lifecycle Hooks |
| 597 | */ |
| 598 | onBeforeMount(() => { |
| 599 | window.scrollTo({ |
| 600 | top: 0, |
| 601 | left: 0, |
| 602 | behavior: 'smooth', |
| 603 | }) |
| 604 | sidebarDataCreator() |
| 605 | }) |
| 606 | |
| 607 | function globalStepLabels() { |
| 608 | let stepLabels = {} |
| 609 | let customizedLabels = amCustomize.value[pageRenderKey.value][stepName.value].translations |
| 610 | if (customizedLabels && Object.keys(customizedLabels)) { |
| 611 | Object.keys(amCustomize.value[pageRenderKey.value][stepName.value].translations).forEach( |
| 612 | (label) => { |
| 613 | stepLabels[label] = |
| 614 | amCustomize.value[pageRenderKey.value][stepName.value].translations[label][langKey.value] |
| 615 | }, |
| 616 | ) |
| 617 | } else { |
| 618 | stepLabels = {} |
| 619 | } |
| 620 | |
| 621 | return stepLabels |
| 622 | } |
| 623 | |
| 624 | function dedicatedStepLabel(label, stepKey) { |
| 625 | let computedLabel = computed(() => { |
| 626 | return amCustomize.value[pageRenderKey.value][stepKey].translations && |
| 627 | amCustomize.value[pageRenderKey.value][stepKey].translations[label] && |
| 628 | amCustomize.value[pageRenderKey.value][stepKey].translations[label][langKey.value] |
| 629 | ? amCustomize.value[pageRenderKey.value][stepKey].translations[label][langKey.value] |
| 630 | : amLabels[label] |
| 631 | }) |
| 632 | |
| 633 | return computedLabel.value |
| 634 | } |
| 635 | |
| 636 | // * Label computed function |
| 637 | function labelsDisplay(label, stepKey) { |
| 638 | let computedLabel = computed(() => { |
| 639 | return amCustomize.value[pageRenderKey.value][stepKey].translations && |
| 640 | amCustomize.value[pageRenderKey.value][stepKey].translations[label] && |
| 641 | amCustomize.value[pageRenderKey.value][stepKey].translations[label][langKey.value] |
| 642 | ? amCustomize.value[pageRenderKey.value][stepKey].translations[label][langKey.value] |
| 643 | : amLabels[label] |
| 644 | }) |
| 645 | |
| 646 | return computedLabel.value |
| 647 | } |
| 648 | |
| 649 | // * Colors |
| 650 | // * Customize colors |
| 651 | let amColors = computed(() => { |
| 652 | const colors = amCustomize.value[pageRenderKey.value] |
| 653 | ? amCustomize.value[pageRenderKey.value].colors |
| 654 | : defaultCustomizeSettings[pageRenderKey.value].colors |
| 655 | |
| 656 | return { ...colors } |
| 657 | }) |
| 658 | |
| 659 | let borderCalculation = computed(() => |
| 660 | containerWidth.value !== 0 && containerWidth.value > 560 |
| 661 | ? amCustomize.value.sbsNew.sidebar.options.self.visibility || sidebarCollapsed.value |
| 662 | : false, |
| 663 | ) |
| 664 | |
| 665 | provide('amColors', amColors) |
| 666 | let cssVars = computed(() => { |
| 667 | return { |
| 668 | '--am-c-primary': amColors.value.colorPrimary, |
| 669 | '--am-c-success': amColors.value.colorSuccess, |
| 670 | '--am-c-error': amColors.value.colorError, |
| 671 | '--am-c-warning': amColors.value.colorWarning, |
| 672 | // input global colors - usage input, textarea, checkbox, radio button, select input, adv select input |
| 673 | '--am-c-inp-bgr': amColors.value.colorInpBgr, |
| 674 | '--am-c-inp-border': amColors.value.colorInpBorder, |
| 675 | '--am-c-inp-text': amColors.value.colorInpText, |
| 676 | '--am-c-inp-placeholder': amColors.value.colorInpPlaceHolder, |
| 677 | // dropdown global colors - usage select dropdown, adv select dropdown |
| 678 | '--am-c-drop-bgr': amColors.value.colorDropBgr, |
| 679 | '--am-c-drop-text': amColors.value.colorDropText, |
| 680 | // sidebar container colors - left part of the form |
| 681 | '--am-c-sb-bgr': amColors.value.colorSbBgr, |
| 682 | '--am-c-sb-text': amColors.value.colorSbText, |
| 683 | // main container colors - right part of the form |
| 684 | '--am-c-main-bgr': amColors.value.colorMainBgr, |
| 685 | '--am-c-main-heading-text': amColors.value.colorMainHeadingText, |
| 686 | '--am-c-main-text': amColors.value.colorMainText, |
| 687 | // button global colors |
| 688 | '--am-c-btn-prim': amColors.value.colorBtnPrim, |
| 689 | '--am-c-btn-prim-text': amColors.value.colorBtnPrimText, |
| 690 | '--am-c-btn-sec': amColors.value.colorBtnSec, |
| 691 | '--am-c-btn-sec-text': amColors.value.colorBtnSecText, |
| 692 | '--am-font-family': amCustomize.value.fonts.fontFamily, |
| 693 | // css properties |
| 694 | // -mw- max width |
| 695 | // -brad- border-radius |
| 696 | '--am-mw-main': amCustomize.value.sbsNew.sidebar.options.self.visibility |
| 697 | ? sidebarCollapsed.value |
| 698 | ? '592px' |
| 699 | : '760px' |
| 700 | : '520px', |
| 701 | '--am-brad-main': borderCalculation.value ? '0 0.5rem 0.5rem 0' : '0.5rem', |
| 702 | } |
| 703 | }) |
| 704 | </script> |
| 705 | |
| 706 | <script> |
| 707 | export default { |
| 708 | name: 'CustomizeStepNew', |
| 709 | } |
| 710 | </script> |
| 711 | |
| 712 | <style lang="scss"> |
| 713 | @import '../../../../assets/scss/common/reset/reset'; |
| 714 | |
| 715 | :root { |
| 716 | // Colors |
| 717 | // shortcuts |
| 718 | // -c- color |
| 719 | // -bgr- background |
| 720 | // -prim- primary |
| 721 | // -sec- secondary |
| 722 | // primitive colors |
| 723 | --am-c-primary: #{$blue-1000}; |
| 724 | --am-c-success: #{$green-1000}; |
| 725 | --am-c-error: #{$red-900}; |
| 726 | --am-c-warning: #{$yellow-1000}; |
| 727 | // main container colors - right part of the form |
| 728 | --am-c-main-bgr: #{$am-white}; |
| 729 | --am-c-main-heading-text: #{$shade-800}; |
| 730 | --am-c-main-text: #{$shade-900}; |
| 731 | // sidebar container colors - left part of the form |
| 732 | --am-c-sb-bgr: #17295a; |
| 733 | --am-c-sb-text: #{$am-white}; |
| 734 | // input global colors - usage input, textarea, checkbox, radio button, select input, adv select input |
| 735 | --am-c-inp-bgr: #{$blue-900}; |
| 736 | --am-c-inp-border: #{$shade-250}; |
| 737 | --am-c-inp-text: #{$shade-900}; |
| 738 | --am-c-inp-placeholder: #{$shade-500}; |
| 739 | --am-c-checkbox-border: #{$shade-300}; |
| 740 | --am-c-checkbox-border-disabled: #{$blue-600}; |
| 741 | --am-c-checkbox-border-focused: #{$blue-700}; |
| 742 | --am-c-checkbox-label-disabled: #{$shade-600}; |
| 743 | // dropdown global colors - usage select dropdown, adv select dropdown |
| 744 | --am-c-drop-bgr: #{$am-white}; |
| 745 | --am-c-drop-text: #{$shade-1000}; |
| 746 | // button global colors |
| 747 | --am-c-btn-prim: #{$blue-900}; |
| 748 | --am-c-btn-prim-text: #{$am-white}; |
| 749 | --am-c-btn-sec: #{$am-white}; |
| 750 | --am-c-btn-sec-text: #{$shade-900}; |
| 751 | |
| 752 | // Properties |
| 753 | // shortcuts |
| 754 | // -h- height |
| 755 | // -fs- font size |
| 756 | // -rad- border radius |
| 757 | --am-h-inp: 40px; |
| 758 | --am-fs-inp: 15px; |
| 759 | --am-rad-inp: 6px; |
| 760 | --am-fs-label: 15px; |
| 761 | --am-fs-btn: 15px; |
| 762 | |
| 763 | // Font |
| 764 | --am-font-family: 'Amelia Roboto', sans-serif; |
| 765 | } |
| 766 | |
| 767 | //@import url('https://fonts.googleapis.com/css2?family=Rampart+One&display=swap'); |
| 768 | // am -- amelia |
| 769 | // fs -- form steps |
| 770 | // sb -- sidebar |
| 771 | #amelia-app-backend-new { |
| 772 | width: 100%; |
| 773 | |
| 774 | * { |
| 775 | font-family: var(--am-font-family); |
| 776 | font-style: initial; |
| 777 | box-sizing: border-box; |
| 778 | word-break: break-word; |
| 779 | letter-spacing: normal; |
| 780 | } |
| 781 | |
| 782 | #amelia-container { |
| 783 | &.am-fs { |
| 784 | // Container Wrapper |
| 785 | &__wrapper { |
| 786 | display: flex; |
| 787 | justify-content: center; |
| 788 | max-width: var(--am-mw-main); |
| 789 | height: 560px; |
| 790 | width: 100%; |
| 791 | box-shadow: 0 30px 40px rgba(0, 0, 0, 0.12); |
| 792 | margin: 16px auto 48px; |
| 793 | border-radius: 8px; |
| 794 | transition: max-width 0.3s ease-in-out; |
| 795 | |
| 796 | &.am-collapsed { |
| 797 | transition-delay: 1s; |
| 798 | } |
| 799 | |
| 800 | .el-form { |
| 801 | &-item { |
| 802 | display: block; |
| 803 | font-family: var(--am-font-family); |
| 804 | font-size: var(--am-fs-label); |
| 805 | margin-bottom: 24px; |
| 806 | |
| 807 | &__label { |
| 808 | flex: 0 0 auto; |
| 809 | text-align: left; |
| 810 | font-size: var(--am-fs-label); |
| 811 | line-height: 1.3; |
| 812 | color: var(--am-c-main-text); |
| 813 | box-sizing: border-box; |
| 814 | margin: 0; |
| 815 | |
| 816 | &:before { |
| 817 | color: var(--am-c-error); |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | &__content { |
| 822 | display: flex; |
| 823 | flex-wrap: wrap; |
| 824 | align-items: center; |
| 825 | flex: 1; |
| 826 | position: relative; |
| 827 | font-size: var(--am-fs-inp); |
| 828 | min-width: 0; |
| 829 | } |
| 830 | |
| 831 | &__error { |
| 832 | font-size: 12px; |
| 833 | color: var(--am-c-error); |
| 834 | padding-top: 4px; |
| 835 | } |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | .el-input { |
| 840 | &__inner { |
| 841 | margin: 0; |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | .am-display-none { |
| 846 | display: none !important; |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | .am-dialog-cs { |
| 853 | z-index: 10000 !important; |
| 854 | } |
| 855 | } |
| 856 | </style> |
| 857 |