/* ---------------------------------------------------------------------------- * Easy!Appointments - Online Appointment Scheduler * * @package EasyAppointments * @author A.Tselegidis * @copyright Copyright (c) Alex Tselegidis * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 * @link https://easyappointments.org * @since v1.5.0 * ---------------------------------------------------------------------------- */ /** * Booking layout. * * This module implements the booking layout functionality. */ window.App.Layouts.Booking = (function () { const $selectLanguage = $('#select-language'); /** * Initialize the module. */ function initialize() { App.Utils.Lang.enableLanguageSelection($selectLanguage); } document.addEventListener('DOMContentLoaded', initialize); return {}; })(); /* ---------------------------------------------------------------------------- * SMB customisation — auto-fit iframe embed. * * EA doesn't report its rendered height, so when embedded in a fixed-height * iframe the wizard overflows and gets its own scrollbar. Here we measure the * wizard card and post its height to the parent page, which resizes the iframe * to fit exactly (see the .booking-embed listener on the client site). Fires on * load, on step changes, when available hours load, and on resize. * ---------------------------------------------------------------------------- */ (function () { function reportHeight() { var el = document.getElementById('book-appointment-wizard'); var h; if (el) { h = Math.ceil(el.getBoundingClientRect().height) + 40; // breathing room } else if (document.body) { h = document.body.scrollHeight; } if (h && h > 0) { try { window.parent.postMessage({ eaBookingHeight: h }, '*'); } catch (e) { /* not embedded / blocked — ignore */ } } } function start() { if (window.parent === window) { return; // not in an iframe, nothing to report } reportHeight(); var target = document.getElementById('book-appointment-wizard') || document.body; if (window.ResizeObserver) { new ResizeObserver(reportHeight).observe(target); } if (window.MutationObserver) { new MutationObserver(reportHeight).observe(target, { subtree: true, childList: true, attributes: true, }); } window.addEventListener('resize', reportHeight); // Catch late async renders (available hours, fade transitions) for a few seconds. var ticks = 0; var iv = setInterval(function () { reportHeight(); if (++ticks > 25) { clearInterval(iv); } }, 250); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start); } else { start(); } })();