From 789c3437b401ffb3589a4cba609b2be175f25b70 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Mon, 14 Nov 2022 20:29:37 -0500 Subject: [PATCH] Allow hiding the contribute banner if you are a supporter or have given. --- js/beestat/setting.js | 4 +++- js/component/card/contribute_banner.js | 17 +++++++++++++++++ js/component/header.js | 8 +++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/js/beestat/setting.js b/js/beestat/setting.js index 8cef0e7..4353799 100644 --- a/js/beestat/setting.js +++ b/js/beestat/setting.js @@ -85,7 +85,9 @@ beestat.setting = function(argument_1, opt_value, opt_callback) { 'date_format': 'M/D/YYYY', - 'units.currency': 'usd' + 'units.currency': 'usd', + + 'hide_contribute_banner': false }; // Figure out what we're trying to do. diff --git a/js/component/card/contribute_banner.js b/js/component/card/contribute_banner.js index 39632e5..fc816bb 100644 --- a/js/component/card/contribute_banner.js +++ b/js/component/card/contribute_banner.js @@ -44,6 +44,23 @@ beestat.component.card.contribute_banner.prototype.decorate_contents_ = function }); tile_group.add_tile(watch_tile); + // Allow dismiss if you are a supporter or if you have given via Stripe. + if ( + beestat.user.contribution_is_active() === true || + Object.keys(beestat.cache.stripe_event).length > 0 + ) { + const dismiss_tile = new beestat.component.tile() + .set_icon('close') + .set_shadow(false) + .set_text_color(beestat.style.color.purple.dark) + .set_text_hover_color(beestat.style.color.purple.light); + dismiss_tile.addEventListener('click', function() { + beestat.setting('hide_contribute_banner', true); + beestat.current_layer.render(); + }); + tile_group.add_tile(dismiss_tile); + } + tile_group.render($(center)); container.appendChild(center); diff --git a/js/component/header.js b/js/component/header.js index 63c64f4..2e048f4 100644 --- a/js/component/header.js +++ b/js/component/header.js @@ -204,7 +204,9 @@ beestat.component.header.prototype.decorate_ = function(parent) { .send(); })); - const contribute_banner = new beestat.component.card.contribute_banner(); - contribute_banner.style({'margin-bottom': `${beestat.style.size.gutter}px`}); - contribute_banner.render(parent); + if (beestat.setting('hide_contribute_banner') === false) { + const contribute_banner = new beestat.component.card.contribute_banner(); + contribute_banner.style({'margin-bottom': `${beestat.style.size.gutter}px`}); + contribute_banner.render(parent); + } };