From e62d4136182950dff4ddda2c1530aa5afab8b833 Mon Sep 17 00:00:00 2001 From: alexk111 Date: Sat, 11 Jan 2020 22:13:31 +0700 Subject: [PATCH] Add donation screen --- src/index.html | 2 +- src/modules/donation.js | 51 +++++++++++++++++++++++++++++++++++++++++ src/modules/page.js | 12 ++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/modules/donation.js diff --git a/src/index.html b/src/index.html index a0935db..6ea21c3 100644 --- a/src/index.html +++ b/src/index.html @@ -42,7 +42,7 @@

DeBitpay

💝 Donations are always appreciated!

- Donate Bitcoin +
diff --git a/src/modules/donation.js b/src/modules/donation.js new file mode 100644 index 0000000..1468230 --- /dev/null +++ b/src/modules/donation.js @@ -0,0 +1,51 @@ +import $ from 'jquery' + +const urlOneTimeAddress = 'https://donate.alexkaul.com/debitpay/widget?isTransparentBg=1' + +const tplScreen = ` +
+ + +
+` + +let $donationScreen +let $preloadLink + +export function showDonationScreen() { + if ($donationScreen) { + $donationScreen.remove() + } + + $donationScreen = $(tplScreen) + $('html').css('overflow', 'hidden') + $donationScreen + .hide() + .appendTo('body') + .fadeIn(300, 'swing') + $('button.close', $donationScreen).click(evt => { + evt.preventDefault() + $donationScreen.fadeOut(300, 'swing', function() { + $(this).remove() + $('html').css('overflow', '') + }) + }) +} + +export function preloadDonationScreen() { + if (!$preloadLink) { + $preloadLink = $(``) // use prefetch, because preload produces a warning for as=document + $preloadLink.appendTo('head') + } +} diff --git a/src/modules/page.js b/src/modules/page.js index 96435e5..2c43cdd 100644 --- a/src/modules/page.js +++ b/src/modules/page.js @@ -7,6 +7,7 @@ import {paymentDataToModalContent} from './paymentModal' import {htmlHowToRunLocally} from './howToRunLocally' import {htmlHowItWorks} from './howItWorks' import {htmlImportantNotice} from './importantNotice' +import {showDonationScreen, preloadDonationScreen} from './donation' const isLocalApp = (window.location.protocol === 'file:') @@ -76,6 +77,16 @@ function initImportantNotice () { }) } +function initDonate() { + $('button.donate').click(evt => { + evt.preventDefault() + showDonationScreen() + }) + $('button.donate').mouseover(_ => { + preloadDonationScreen() + }) +} + function initFooter () { btnToCopyBtn($('footer .btn-clipboard')) } @@ -90,6 +101,7 @@ export function initPage () { initHowToRunLocally() initHowItWorks() initImportantNotice() + initDonate() initFooter() loadingDone() }