// // Vex modals // /* global vex, fetch, Clipboard */ /* exported krlcModals */ /* eslint-disable spaced-comment */ //=require vex-js/dist/js/vex.combined.js //=require clipboard/dist/clipboard.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}
` }) const clipboard = new Clipboard('.btn') clipboard.on('success', e => { e.trigger.classList.add('success') console.info('Action:', e.action) console.info('Text:', e.text) console.info('Trigger:', e.trigger) e.clearSelection() }) }) }) } } return { init() { _private.getBtcAddress() _private.vexBtc() } } })(); // eslint-disable-line semi