Skip to content
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

Add register to vote banner #1934

Merged
merged 1 commit into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/stylesheets/helpers/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
background-color: #E5EAF1;
display: none;
padding: 15px 0;
border-top: 8px solid #E61E32;
border-top: 8px solid $govuk-blue;

.show-global-bar & {
display: block;
Expand Down
16 changes: 10 additions & 6 deletions app/views/notifications/_global_bar.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<%
show_global_bar ||= false # Toggles the appearance of the global bar
title = "A Brexit deal has been agreed but needs to be ratified"
link_href = "/brexit"
link_text = "Find out what this means for you"
require 'date'

show_global_bar ||= true # Toggles the appearance of the global bar
title = "Register to vote"
link_href = "/register-to-vote"
link_text = "Register by 26 November to vote in the General Election on 12 December."
close_date = DateTime.new(2019,11,26,23,59,00) # DateTime after which the bar will automatically disappear, or false to unset
vanitabarrett marked this conversation as resolved.
Show resolved Hide resolved
-%>
<% if show_global_bar %>

<% if show_global_bar && (!close_date || DateTime.now() < close_date) %>
<% content_for :head do %>
<!--[if gt IE 7]><!-->
<script>
// Bump this if you are releasing a major change to the banner
// This will reset the view count so all users will see the banner, even if previously seen
COOKIE_VERSION = 2;
COOKIE_VERSION = 3;

!function(e,o=COOKIE_VERSION){function n(){var e=new Date(Date.now()+72576e5).toUTCString();document.cookie='global_bar_seen={"count":0,"version":'+o+"}; expires="+e+";"}var t,a,r,c=e.documentElement;!/^\/register-to-vote|^\/done|^\/brexit|^\/get-ready-brexit-check/.test(window.location.pathname)&&(a=document.cookie.match("(?:^|[ ;])(?:global_bar_seen=)(.+?)(?:(?=;|$))"),r=!1,null===a?(n(),r=!0):(t=a[1],void 0===JSON.parse(t).version||JSON.parse(a[1]).version!==o?(n(),r=!0):(a=JSON.parse(a[1]),r=parseInt(a.count,10)<3)),r)&&(c.className=c.className.concat(" show-global-bar"))}(document);
</script>
Expand Down