1/* Forexive pricing table: toggles server-rendered panels. Bricks calls fxptInit() on load and after builder re-renders. */ 2(function () { 3 var SWAP_MS = 170; 4 5 function moveIndicator(group) { 6 var ind = group.querySelector('.fxpt__ind'); 7 var active = group.querySelector('.fxpt__pill[aria-selected="true"]'); 8 if (!ind || !active || group.hidden || !active.offsetWidth) return; 9 ind.style.width = active.offsetWidth + 'px'; 10 ind.style.transform = 'translateX(' + active.offsetLeft + 'px)'; 11 if (!group.classList.contains('is-ready')) { 12 // First placement: skip the slide-in animation. 13 ind.style.transition = 'none'; 14 group.classList.add('is-ready'); 15 ind.offsetWidth; // eslint-disable-line no-unused-expressions 16 ind.style.transition = ''; 17 } 18 } 19 20 function select(group, pill) { 21 group.querySelectorAll('.fxpt__pill').forEach(function (p) { 22 p.setAttribute('aria-selected', p === pill ? 'true' : 'false'); 23 }); 24 moveIndicator(group); 25 } 26 27 function applyPlan(root, prog, i) { 28 var panel = root.querySelector('.fxpt__prog[data-p="' + prog + '"]'); 29 if (!panel) return; 30 var plan = JSON.parse(panel.dataset.plans || '[]')[i]; 31 if (!plan) return; 32 panel.querySelectorAll('[data-fx="s"]').forEach(function (el) { el.textContent = plan.s; }); 33 panel.querySelectorAll('[data-fx="p"]').forEach(function (el) { el.textContent = plan.p; }); 34 panel.querySelectorAll('.fxpt__btn').forEach(function (el) { el.href = plan.u; }); 35 panel.querySelectorAll('[data-pv]').forEach(function (el) { 36 var v = JSON.parse(el.dataset.pv)[i]; 37 el.textContent = v == null ? '-' : v; 38 }); 39 } 40 41 function showProgram(root, prog) { 42 root.querySelectorAll('.fxpt__prog').forEach(function (el) { el.hidden = el.dataset.p !== prog; }); 43 root.querySelectorAll('.fxpt__group[data-g="plan"]').forEach(function (el) { el.hidden = el.dataset.p !== prog; }); 44 var plans = root.querySelector('.fxpt__group[data-g="plan"][data-p="' + prog + '"]'); 45 if (plans) moveIndicator(plans); 46 } 47 48 function swap(root, fn) { 49 if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) { fn(); return; } 50 clearTimeout(root._fxptT); 51 root.classList.add('is-swapping'); 52 root._fxptT = setTimeout(function () { 53 fn(); 54 root.offsetWidth; // eslint-disable-line no-unused-expressions -- commit the faded state so the fade-in transitions 55 root.classList.remove('is-swapping'); 56 }, SWAP_MS); 57 } 58 59 function onClick(e) { 60 var pill = e.target.closest('.fxpt__pill'); 61 if (!pill) return; 62 var group = pill.parentElement; 63 var root = this; 64 if (pill.getAttribute('aria-selected') === 'true') return; 65 select(group, pill); 66 67 if (group.dataset.g === 'tab') { 68 var t = pill.dataset.t; 69 var sub = null; 70 root.querySelectorAll('.fxpt__group[data-g="sub"]').forEach(function (el) { 71 el.hidden = el.dataset.t !== t; 72 if (!el.hidden) sub = el; 73 }); 74 // Remember the sub-tab last chosen inside this tab. 75 var prog = sub ? sub.querySelector('[aria-selected="true"]').dataset.p : pill.dataset.p; 76 if (sub) moveIndicator(sub); 77 swap(root, function () { showProgram(root, prog); }); 78 } else if (group.dataset.g === 'sub') { 79 swap(root, function () { showProgram(root, pill.dataset.p); }); 80 } else { 81 swap(root, function () { applyPlan(root, group.dataset.p, +pill.dataset.i); }); 82 } 83 } 84 85 function layoutAll() { 86 document.querySelectorAll('.fxpt .fxpt__group:not([hidden])').forEach(moveIndicator); 87 } 88 89 window.fxptInit = function () { 90 document.querySelectorAll('.fxpt').forEach(function (root) { 91 if (root._fxpt) return; 92 root._fxpt = true; 93 root.addEventListener('click', onClick); 94 root.querySelectorAll('.fxpt__group:not([hidden])').forEach(moveIndicator); 95 }); 96 }; 97 98 var rafId; 99 window.addEventListener('resize', function () { 100 cancelAnimationFrame(rafId); 101 rafId = requestAnimationFrame(layoutAll); 102 }, { passive: true }); 103 if (document.fonts && document.fonts.ready) document.fonts.ready.then(layoutAll); 104 105 if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', window.fxptInit); 106 else window.fxptInit(); 107})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.