All rentals
Loading...
(function () { if (window.PPEC_SMALL_TOWN_CARNIVAL_READY) return; window.PPEC_SMALL_TOWN_CARNIVAL_READY = true; var STORAGE_KEY = 'ppec_global_quote_v4'; var INV_URL = '/wp-json/partypros-webmcp/v1/inventory'; var BOOTH_IDS = [ 'ring-toss', 'frog-hop', 'can-smash', 'cover-the-spot', 'cover-the-star', 'dice-game', 'fish-pond', 'milk-the-cow', 'piggy-race', 'potty-toss', 'stand-it-bottle', 'tic-tac-toe', 'troll-toss', 'tubs-of-fun', 'clown-teeth-knockout' ]; var EXACT = 2; var activeMode = 'addon'; // 'addon' | 'package' function loadCart() { try { var a = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]'); return Array.isArray(a) ? a : []; } catch (e) { return []; } } function saveCart(cart) { localStorage.setItem(STORAGE_KEY, JSON.stringify(cart)); try { if (typeof window.ppHomeQuoteUpdate === 'function') window.ppHomeQuoteUpdate(); } catch (e) {} try { window.dispatchEvent(new CustomEvent('ppe:globalQuoteUpdated')); } catch (e) {} } function toast(msg) { var t = document.getElementById('ppe-stc-toast'); if (!t) { t = document.createElement('div'); t.id = 'ppe-stc-toast'; t.style.cssText = 'position:fixed;left:50%;bottom:88px;transform:translateX(-50%);z-index:1000003;background:#0f172a;color:#fff;padding:10px 14px;border-radius:10px;font:600 14px/1.3 system-ui,sans-serif;max-width:90vw;opacity:0;transition:opacity .2s'; document.body.appendChild(t); } t.textContent = msg; t.style.opacity = '1'; setTimeout(function () { t.style.opacity = '0'; }, 2200); } function ensureUi() { if (document.getElementById('ppe-stc-css')) return; var s = document.createElement('style'); s.id = 'ppe-stc-css'; s.textContent = [ '#ppe-stc-modal{position:fixed;inset:0;z-index:1000002;display:flex;align-items:flex-end;justify-content:center;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif}', '#ppe-stc-modal[hidden]{display:none!important}', '#ppe-stc-modal .ppe-stc-back{position:absolute;inset:0;background:rgba(15,23,42,.55)}', '#ppe-stc-modal .ppe-stc-sheet{position:relative;z-index:1;width:100%;max-width:560px;max-height:min(88vh,720px);background:#fff;border-radius:16px 16px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);display:flex;flex-direction:column;overflow:hidden}', '@media(min-width:768px){#ppe-stc-modal{align-items:center}#ppe-stc-modal .ppe-stc-sheet{border-radius:16px}}', '#ppe-stc-modal .ppe-stc-head{padding:16px;border-bottom:1px solid #e2e8f0;display:flex;justify-content:space-between;gap:12px}', '#ppe-stc-modal .ppe-stc-head .ppe-stc-title{margin:0;font-size:1.15rem;color:#321854;font-weight:700}', '#ppe-stc-modal .ppe-stc-head p{margin:4px 0 0;color:#64748b;font-size:.9rem}', '#ppe-stc-modal .ppe-stc-x{border:0;background:#f1f5f9;width:36px;height:36px;border-radius:999px;font-size:20px;cursor:pointer}', '#ppe-stc-modal .ppe-stc-list{overflow:auto;padding:8px 12px;flex:1}', '#ppe-stc-modal .ppe-stc-row{display:flex;gap:12px;align-items:center;padding:10px;border:1px solid #e2e8f0;border-radius:12px;margin:0 0 8px;cursor:pointer}', '#ppe-stc-modal .ppe-stc-row.is-on{border-color:#01847f;background:#f0fdfa}', '#ppe-stc-modal .ppe-stc-row img{width:56px;height:56px;object-fit:cover;border-radius:8px;background:#f8fafc}', '#ppe-stc-modal .ppe-stc-row .n{font-weight:700;color:#0f172a}', '#ppe-stc-modal .ppe-stc-foot{padding:12px 16px calc(72px + env(safe-area-inset-bottom,0px));border-top:1px solid #e2e8f0;display:flex;gap:10px}', '#ppe-stc-modal .ppe-stc-foot button{flex:1;min-height:48px;border-radius:10px;border:0;font-weight:800;cursor:pointer}', '#ppe-stc-modal .ppe-stc-go{background:#321854;color:#fff}', '#ppe-stc-modal .ppe-stc-go:disabled{opacity:.45;cursor:default}', '#ppe-stc-modal .ppe-stc-cancel{background:#f1f5f9;color:#334155}', 'html.ppe-stc-open .ppw-floating-picker,html.ppe-stc-open #ppec-global-quote-root .ppec-gq-fabs{visibility:hidden!important;pointer-events:none!important}' ].join(''); document.head.appendChild(s); } function closeModal() { var el = document.getElementById('ppe-stc-modal'); if (el) el.hidden = true; document.body.style.overflow = ''; document.documentElement.classList.remove('ppe-stc-open'); } function selected() { return Array.prototype.slice.call(document.querySelectorAll('#ppe-stc-modal .ppe-stc-row input:checked')); } function syncBtn() { var n = selected().length; var btn = document.getElementById('ppe-stc-go'); if (!btn) return; btn.disabled = n !== EXACT; btn.textContent = n === EXACT ? 'Add package with 2 booth games' : ('Select exactly 2 (' + n + '/2)'); } function confirmPackage() { var boxes = selected(); if (boxes.length !== EXACT) { toast('Select exactly 2 booth games'); return; } var byId = window.__ppeStcInv || {}; var picked = []; boxes.forEach(function (b) { var it = byId[b.value]; if (it) picked.push(it); }); if (picked.length !== EXACT) return; var cart = loadCart(); if (activeMode === 'package') { cart = cart.filter(function (x) { return x.id !== 'small-town-carnival'; }); cart.push({ id: 'small-town-carnival', title: 'Small Town Carnival', details: ['Carousel', 'High Striker', picked[0].name, picked[1].name, 'Popcorn Machine'], kind: 'package', url: location.pathname, source: 'carnival-booth-picker' }); } picked.forEach(function (it) { if (!cart.some(function (x) { return x.id === it.id; })) { cart.push({ id: it.id, title: it.name, details: ['Carnival Booth Game', 'Pick 2 booth games'], kind: 'item', url: it.url || '', source: 'carnival-booth-picker' }); } }); saveCart(cart); closeModal(); toast(activeMode === 'package' ? 'Small Town Carnival + 2 booth games added' : '2 Carnival Booth Games added to quote'); } function openModal(items) { ensureUi(); var el = document.getElementById('ppe-stc-modal'); if (!el) { el = document.createElement('div'); el.id = 'ppe-stc-modal'; el.hidden = true; el.setAttribute('role', 'dialog'); el.setAttribute('aria-modal', 'true'); el.innerHTML = '' + '
' + 'Choose exactly two carnival tabletop booth games.
No booth games found.
'; var sub = document.getElementById('ppe-stc-sub'); if (sub) { sub.textContent = activeMode === 'package' ? 'Small Town Carnival includes two tabletop booth games. Choose exactly two.' : 'Carnival Booth Games: pick exactly two tabletop booth games for your quote.'; } el.hidden = false; document.body.style.overflow = 'hidden'; document.documentElement.classList.add('ppe-stc-open'); syncBtn(); } function isTarget(btn) { if (!btn || !btn.classList.contains('pp-add-to-quote')) return false; var id = (btn.getAttribute('data-quote-id') || '').toLowerCase(); var title = (btn.getAttribute('data-quote-title') || '').toLowerCase(); if (id === 'small-town-carnival') return true; if (id === 'ring-toss' || id === 'carnival-booth-games' || id === 'carnival-booth-rentals') return true; if (title.indexOf('small town carnival') !== -1) return true; if (title.indexOf('carnival booth') !== -1) return true; if (title === 'ring toss') return true; var pack = btn.closest('.pp-package'); if (pack && /small town carnival/i.test(pack.getAttribute('data-item-title') || '')) return true; var card = btn.closest('.pp-card'); if (card) { var ct = (card.getAttribute('data-item-title') || '').toLowerCase(); var cid = (card.id || '').toLowerCase(); if (ct === 'ring toss' || ct.indexOf('carnival booth') !== -1) return true; if (cid === 'pp-ring-toss' || cid === 'pp-carnival-booth-games') return true; } return false; } document.addEventListener('click', function (e) { var btn = e.target.closest('.pp-add-to-quote, .package-btn'); if (!isTarget(btn)) return; e.preventDefault(); e.stopPropagation(); if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation(); fetch(INV_URL, { credentials: 'same-origin' }) .then(function (r) { return r.json(); }) .then(function (data) { var items = (data && data.items) || []; var byId = {}; items.forEach(function (it) { byId[it.id] = it; }); window.__ppeStcInv = byId; var list = []; BOOTH_IDS.forEach(function (id) { if (byId[id]) list.push(byId[id]); }); var id = (btn.getAttribute('data-quote-id') || '').toLowerCase(); var title = (btn.getAttribute('data-quote-title') || '').toLowerCase(); activeMode = (id === 'small-town-carnival' || title.indexOf('small town carnival') !== -1) ? 'package' : 'addon'; openModal(list); }) .catch(function () { toast('Could not load booth games. Try again.'); }); }, true); })();