/* RTE Exam Prep landing page Loaded only by resources/views/user/rte-landing.blade.php. Both blocks are plain IIFEs rather than $(document).ready callbacks: on this site that ready queue throws (`$(...).easyPieChart is not a function`) and none of its handlers attach, which is why the mobile menu is driven from bootstrap's own collapse events below. */ // FAQ accordion // The plus/minus is drawn by .rte-faq__icon in CSS off the is-open class, so // there is no icon element to swap - only the class and the aria state. (function () { var items = document.querySelectorAll('.page-rte-landing .rte-faq__item'); if (!items.length) return; function setState(item, open) { item.classList.toggle('is-open', open); item.querySelector('.rte-faq__q').setAttribute('aria-expanded', open ? 'true' : 'false'); item.querySelector('.rte-faq__a').hidden = !open; } items.forEach(function (item) { item.querySelector('.rte-faq__q').addEventListener('click', function () { var open = !item.classList.contains('is-open'); items.forEach(function (i) { setState(i, false); }); if (open) setState(item, true); }); }); }()); // Mobile navigation // Driven by bootstrap's collapse events rather than by the click handler in // the $(document).ready block above: none of that block's handlers are // attached on the homepage (see the easyPieChart TypeError it throws), so the // body class and the dimmer were never being set. Written as a plain IIFE so // it cannot be taken down with it. (function () { var panel = document.getElementById('navbarSupportedContent'); if (!panel || !window.bootstrap) return; var overlay = document.querySelector('.mobile-menu-overlay'); var close = panel.querySelector('.btn-close'); panel.addEventListener('show.bs.collapse', function () { document.body.classList.add('menu-open'); }); panel.addEventListener('hide.bs.collapse', function () { document.body.classList.remove('menu-open'); }); function hide() { bootstrap.Collapse.getOrCreateInstance(panel).hide(); } if (overlay) overlay.addEventListener('click', hide); if (close) close.addEventListener('click', hide); // Following an in-page anchor should close the panel behind it panel.querySelectorAll('a[href*="#"]').forEach(function (a) { a.addEventListener('click', hide); }); }());