/** * Public invoice / quote page. * * Everything the action bar does: print, PDF, send by email, the payment * panel, accepting or declining a quote, and the administrator's per-document * CSS editor. Configuration arrives in `easyInvoiceDocument` (localised by * DocumentPage::enqueue). */ (function ($) { 'use strict'; var cfg = window.easyInvoiceDocument || {}; var i18n = cfg.i18n || {}; var isQuote = cfg.type === 'quote'; /* ------------------------------------------------------------------ */ /* Modal */ /* ------------------------------------------------------------------ */ function closeModal(overlay) { if (!overlay) { return; } overlay.classList.remove('show'); var modal = overlay.querySelector('.ei-modal'); if (modal) { modal.classList.remove('show'); } setTimeout(function () { if (overlay.parentNode) { overlay.parentNode.removeChild(overlay); } }, 200); } function closeAnyModal() { var existing = document.querySelector('.ei-modal-overlay'); if (existing) { closeModal(existing); } } function iconFor(kind) { return { info: '?', danger: '!', success: '✓', error: '✕' }[kind] || '?'; } /** * Build a modal. * * @param {Object} o title, message, kind (info|danger|success|error), * confirmText, cancelText, reasonLabel (adds a textarea), onConfirm(reason, buttons) */ function openModal(o) { closeAnyModal(); var overlay = document.createElement('div'); overlay.className = 'ei-modal-overlay'; overlay.setAttribute('role', 'dialog'); overlay.setAttribute('aria-modal', 'true'); var reasonField = o.reasonLabel ? '' + '' : ''; var buttons = o.confirmText ? '' + '' : ''; overlay.innerHTML = '