-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: donation banner tweaks #7703
Changes from 2 commits
5affee0
2eadb40
5682a53
14a6546
a7d2ba2
1291831
a1484a5
204edea
e4d5cd9
94cc22c
04f9deb
0a99d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -3,54 +3,69 @@ | |||
|
||||
[% IF banner %] | ||||
|
||||
<div id="donate_banner" class="block black short" style="background-color:#6D85D9"> | ||||
|
||||
<div id="donate_image_banner_outside"> | ||||
<div class="row hide-for-small"> | ||||
|
||||
<div id="donate_image_banner_inside"> | ||||
|
||||
<a href="[% link %]?utm_source=off&utm_medium=web&utm_campaign=donate-2022&utm_term=en-text-button" class="button round white-button" style="float:left;margin-right:2rem;"> | ||||
<span class="material-icons material-symbols-button">volunteer_activism</span> | ||||
[% lang('donation_cta') %] | ||||
</a> | ||||
|
||||
<p class="">[% f_lang('donation_body_employees', { number_of_employees => '7' }) %]<br> | ||||
[% f_lang('donation_why_year', { year => '2022' }) %] <strong>[% lang('thank_you') %] <span style="color:red">❤️</span></strong> | ||||
</p> | ||||
<input id="hide_image_banner" type="checkbox" style="margin-top:1.5rem;margin-bottom:0;"> | ||||
<label for="hide_image_banner"> | ||||
<span id="hide_image_banner_hide"class="text-white">[% lang('donation_banner_hide') %]</span> | ||||
</label> | ||||
|
||||
</div> | ||||
</div> | ||||
|
||||
<div class="row hide-for-medium-up"> | ||||
|
||||
<div id="donate_image_banner_inside" style="min-height:90px;padding-top:10px;"> | ||||
|
||||
<a href="[% link %]?utm_source=off&utm_medium=web&utm_campaign=donate-2022&utm_term=en-text-button" class="button round white-button" style="float:left;margin-right:2rem;"> | ||||
<span class="material-icons material-symbols-button">volunteer_activism</span> | ||||
[% lang('donation_cta') %] | ||||
</a> | ||||
</div> | ||||
|
||||
<div class="small-12 columns"> | ||||
<p class="">[% f_lang('donation_body_employees', { number_of_employees => '7' }) %]<br> | ||||
[% f_lang('donation_why_year', { year => '2022' }) %] <strong>[% lang('thank_you') %] <span style="color:red">❤️</span></strong> | ||||
</p> | ||||
<input id="hide_image_banner" type="checkbox" style="margin-top:1.5rem;margin-bottom:0;"> | ||||
<label for="hide_image_banner"> | ||||
<span id="hide_image_banner_hide"class="text-white">[% lang('donation_banner_hide') %]</span> | ||||
</label> | ||||
|
||||
</div> | ||||
</div> | ||||
|
||||
</div> | ||||
|
||||
</div> | ||||
<section id="donate-banner"> | ||||
<span id="donate-banner__image"></span> | ||||
<div id="donate-banner__content"> | ||||
<a href="[% link %]?utm_source=off&utm_medium=web&utm_campaign=donate-2022&utm_term=en-text-button" | ||||
class="button round white-button"> | ||||
<span class="material-icons">volunteer_activism</span> | ||||
[% lang('donation_cta') %] | ||||
</a> | ||||
<div class="banner-content"> | ||||
<p>[% f_lang('donation_body_employees', { number_of_employees => '7' }) %] [% f_lang('donation_why_year', { year => '2022' }) %]</p> | ||||
<p>[% lang('thank_you') %] <span>❤️</span></p> | ||||
</div> | ||||
<div class="banner__close"> | ||||
<span id="hide-donate-banner" onclick="DonationButton();" class="material-icons banner__close--icon">close</span> | ||||
</div> | ||||
</div> | ||||
</section> | ||||
|
||||
<script> | ||||
let d = new Date(); | ||||
let expires = 'expires=' + d.toUTCString(); | ||||
let bannerID = document.getElementById('donate-banner'); | ||||
let bcval = "1"; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems we don't need this any-more ? |
||||
|
||||
function setBannerCookie(bcname, bcval, bcexdays) { | ||||
d.setTime(d.getTime() + (bcexdays*60*60*24*1000)); | ||||
let expires = 'expires=' + d.toUTCString(); | ||||
document.cookie = bcname + '=' + bcval + ';' + expires + ';path=/'; | ||||
console.log(expires); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should remove this :-)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, forgot about those! Thank you, I will remove it soon, also unused vars and logs. |
||||
} | ||||
|
||||
|
||||
function deleteBannerCookie(bcname) { | ||||
d.setTime(d.getTime() + (60*60*24*1000)); | ||||
let expires = 'expires=' + d.toUTCString(); | ||||
document.cookie = bcname + '=;' + expires + ';path=/'; | ||||
} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this, and not only call setBannerCookie ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's like a double-check for me - cleans the cookie value and set expire for current time, if you feel like it is not really important I can test the code without it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, it's ok if we keep it, but maybe a comment to explain is good :-) |
||||
|
||||
function getBannerCookie(bcname) { | ||||
let name = bcname + '='; | ||||
let decodedCookie = decodeURIComponent(document.cookie); | ||||
let ca = decodedCookie.split(';'); | ||||
for (let i = 0; i < ca.length; i++) { | ||||
let c = ca[i]; | ||||
while (c.charAt(0) == ' ') { c = c.substring(1); } | ||||
if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } | ||||
} | ||||
return ''; | ||||
} | ||||
|
||||
function DonationButton() { | ||||
deleteBannerCookie('off-donation-banner'); | ||||
setBannerCookie('off-donation-banner', 1, 14); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I seems to me 14 days is not enough, it's a bit pushy to users. If I donate, I would expect this not to show up again for at least 180 days ! If possible, I would set it on whole openfoodfacts.xx subdomain (not only for eg. world) (that is you can set domain to the last two components of domain). @teolemon what is your though ? |
||||
bannerID.style.display = 'none'; | ||||
} | ||||
|
||||
if (getBannerCookie('off-donation-banner') != '') { | ||||
bannerID.style.display = 'none'; | ||||
} else { | ||||
bannerID.style.display = 'flex'; | ||||
} | ||||
</script> | ||||
|
||||
[% END %] | ||||
|
||||
<!-- end templates/[% component.name %] --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems we don't need this any-more ?