Make Hero Banner closable (#6333) [deploy]
* feat: set up an event handler that will allow close the banner and set a cookie when you've closed it * feat: return early if the cookie says it shouldn't be shown * refactor: make the names more general so that they can be applied to other campaigns
This commit is contained in:
parent
da133bcbb5
commit
55909afdc7
3 changed files with 15 additions and 2 deletions
|
|
@ -45,8 +45,8 @@ function callInitalizers(){
|
|||
initializeCreditsPage();
|
||||
initializeUserProfilePage();
|
||||
initializePodcastPlayback();
|
||||
|
||||
initializeDrawerSliders();
|
||||
initializeHeroBannerClose();
|
||||
|
||||
function freezeScrolling(event){
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
function initializeHeroBannerClose() {
|
||||
let banner = document.getElementById("js-hero-banner");
|
||||
let closeIcon = document.getElementById("js-hero-banner__x");
|
||||
|
||||
if (banner && closeIcon) {
|
||||
closeIcon.onclick = (e) => {
|
||||
document.cookie = "heroBanner=false";
|
||||
banner.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class StoriesController < ApplicationController
|
|||
private
|
||||
|
||||
def assign_hero_html
|
||||
return if SiteConfig.campaign_hero_html_variant_name.blank?
|
||||
return if SiteConfig.campaign_hero_html_variant_name.blank? || cookies[:heroBanner] == "false"
|
||||
|
||||
@hero_html = HtmlVariant.relevant.select(:html).
|
||||
find_by(group: "campaign", name: SiteConfig.campaign_hero_html_variant_name)&.html
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue