Skip to content

Commit

Permalink
Merge pull request #1955 from alphagov/test-permanent-banner
Browse files Browse the repository at this point in the history
Add ability to make global banner permanent
  • Loading branch information
Vanita Barrett authored Dec 3, 2019
2 parents ce77c63 + 5e8dede commit cd7f07a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/modules/global-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -25,7 +26,9 @@


if ($el.is(':visible')) {
incrementViewCount(count);
if (!always_on) {
incrementViewCount(count);
}
track('Viewed');
}

Expand Down
7 changes: 6 additions & 1 deletion app/views/notifications/_global_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -19,7 +24,7 @@
<!--<![endif]-->
<% end %>
<!--[if gt IE 7]><!-->
<div id="global-bar" class="global-bar dont-print" data-module="global-bar">
<div id="global-bar" class="global-bar dont-print" data-module="global-bar" <%= "data-global-bar-permanent=true" if always_visible %>>
<div class="global-bar-message-container">
<p class="global-bar-message">
<% if title %>
Expand Down

0 comments on commit cd7f07a

Please sign in to comment.