From 5e8dede3f2b63f1f32d77524fd34fa3b789f1e14 Mon Sep 17 00:00:00 2001 From: Vanita Barrett Date: Mon, 2 Dec 2019 15:23:01 +0000 Subject: [PATCH] Add ability to make global banner permanent The default behaviour of the banner is to show for 3 pageviews, and then automatically hide. It can also be manually dismissed by the user. We want the ability to have the banner be permanent, i.e: it will always show, regardless of the number of pageviews. This won't affect the user's ability to manually dismiss the banner. --- app/assets/javascripts/modules/global-bar.js | 5 ++++- app/views/notifications/_global_bar.html.erb | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/modules/global-bar.js b/app/assets/javascripts/modules/global-bar.js index b4d0ed47b..738ddf728 100644 --- a/app/assets/javascripts/modules/global-bar.js +++ b/app/assets/javascripts/modules/global-bar.js @@ -10,6 +10,7 @@ Modules.GlobalBar = function() { this.start = function($el) { var GLOBAL_BAR_SEEN_COOKIE = "global_bar_seen"; + var always_on = $el.data("global-bar-permanent"); // If the cookie is not set, let's set a basic one if (GOVUK.getCookie(GLOBAL_BAR_SEEN_COOKIE) === null || JSON.parse(GOVUK.getCookie(GLOBAL_BAR_SEEN_COOKIE))["count"] === undefined) { @@ -25,7 +26,9 @@ if ($el.is(':visible')) { - incrementViewCount(count); + if (!always_on) { + incrementViewCount(count); + } track('Viewed'); } diff --git a/app/views/notifications/_global_bar.html.erb b/app/views/notifications/_global_bar.html.erb index 77d30a6e8..78fbf489a 100644 --- a/app/views/notifications/_global_bar.html.erb +++ b/app/views/notifications/_global_bar.html.erb @@ -4,6 +4,11 @@ title_href = "/register-to-vote" link_text = "Register by 26 November to vote in the General Election on 12 December." link_href = false + + # Toggles banner being permanently visible + # If true, banner is always_visible & does not disappear automatically after 3 pageviews + # Regardless of value, banner is always manually dismissable by users + always_visible = false -%> <% if show_global_bar %> @@ -19,7 +24,7 @@ <% end %> -
+
>

<% if title %>