diff --git a/app/assets/javascripts/modules/global-bar.js b/app/assets/javascripts/modules/global-bar.js index ed6a6800d..00455233e 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", + current_cookie_version = JSON.parse(GOVUK.getCookie(GLOBAL_BAR_SEEN_COOKIE))["version"], count = viewCount(); $el.on('click', '.dismiss', hide); @@ -29,7 +30,8 @@ function hide(evt) { $el.hide(); - GOVUK.setCookie(GLOBAL_BAR_SEEN_COOKIE, 999, {days: 84}); + var cookie_value = JSON.stringify({"count": 999, "version": current_cookie_version}); + GOVUK.setCookie(GLOBAL_BAR_SEEN_COOKIE, cookie_value, {days: 84}); track('Manually dismissed'); $('html').removeClass('show-global-bar'); evt.preventDefault(); @@ -37,7 +39,8 @@ function incrementViewCount(count) { count = count + 1; - GOVUK.setCookie(GLOBAL_BAR_SEEN_COOKIE, count, {days: 84}); + var cookie_value = JSON.stringify({"count": count, "version": current_cookie_version}); + GOVUK.setCookie(GLOBAL_BAR_SEEN_COOKIE, cookie_value, {days: 84}); if (count == 2) { track('Automatically dismissed'); @@ -46,7 +49,7 @@ function viewCount() { var viewCountCookie = GOVUK.getCookie(GLOBAL_BAR_SEEN_COOKIE), - viewCount = parseInt(viewCountCookie, 10); + viewCount = parseInt(JSON.parse(viewCountCookie)["count"],10); if (isNaN(viewCount)) { viewCount = 0; diff --git a/app/views/notifications/_global_bar.html.erb b/app/views/notifications/_global_bar.html.erb index 3fe8a342f..744168596 100644 --- a/app/views/notifications/_global_bar.html.erb +++ b/app/views/notifications/_global_bar.html.erb @@ -7,7 +7,13 @@ <% if show_global_bar %> <% content_for :head do %> - + <% end %>