// // Vex modals // /* global vex, fetch, ClipboardJS, QRious */ /* exported krlcModals */ /* eslint-disable spaced-comment */ //=require vex-js/dist/js/vex.combined.js //=require clipboard/dist/clipboard.js //=require qrious/dist/qrious.js /* eslint-enable spaced-comment */ const krlcModals = (() => { // eslint-disable-line no-unused-vars const _config = { btcVexTriggers: document.querySelectorAll('.js-vex-btc') } let btcAddress let ethAddress const _private = { getBtcAddress() { const url = '/api/site.json' fetch(url) .then(res => res.json()) .then(data_ => { btcAddress = data_[0].author.bitcoin ethAddress = data_[0].author.ether }) .catch(err => console.error(err)) return { btcAddress, ethAddress } }, vexBtc() { _config.btcVexTriggers.forEach(el => { el.addEventListener('click', e => { e.preventDefault() vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin' vex.dialog.buttons.YES.text = 'Close' vex.open({ unsafeContent: `

Say thanks

Bitcoin

${btcAddress}

Ethereum

${ethAddress}
` }) // Generate QR codes const qrBtc = new QRious({ element: document.getElementById('qr-btc'), value: btcAddress }) const qrEth = new QRious({ element: document.getElementById('qr-eth'), value: ethAddress }) const qrOptions = { backgroundAlpha: 0, foreground: '#6b7f88', size: 160 } qrBtc.set(qrOptions) qrEth.set(qrOptions) // Clipboard button const clipboard = new ClipboardJS('.btn') clipboard.on('success', e => { e.trigger.classList.add('success') e.clearSelection() }) }) }) } } return { init() { _private.getBtcAddress() _private.vexBtc() } } })(); // eslint-disable-line semi