diff --git a/app/assets/javascripts/browser-check.js b/app/assets/javascripts/browser-check.js index 999309039..eff770eb0 100644 --- a/app/assets/javascripts/browser-check.js +++ b/app/assets/javascripts/browser-check.js @@ -1,22 +1,35 @@ +/*globals $, getCookie, suchi, setCookie */ +/*jslint + white: true, + browser: true */ + $(function() { - - // we don't show the message when the cookie warning is also there + "use strict"; + function browserWarning() { + var container = $('
'), + text = $('For a safer, faster, better experience online you should upgrade your browser.
'), + findMoreLink = $('Find out more about browsers'), + closeLink = $('Close'); + + return container.append(text.append(findMoreLink, closeLink)); + } + + // we don't show the message when the cookie warning is also there if (getCookie('seen_cookie_message')) { - if ( suchi.isOld(navigator.userAgent) ) { - if(getCookie('govuk_not_first_visit') !== null && getCookie('govuk_browser_upgrade_dismissed') === null){ - var $prompt = $("#global-browser-prompt"); - $prompt.show(); - $prompt.find(".dismiss").on("click", function(){ - $prompt.hide(); - // the warning is dismissable for 2 weeks - setCookie('govuk_browser_upgrade_dismissed', 'yes', 14); - return false; - }); - } - } - + if (suchi.isOld(navigator.userAgent)) { + if(getCookie('govuk_not_first_visit') !== null && getCookie('govuk_browser_upgrade_dismissed') === null){ + var $prompt = browserWarning(); + $('#global-cookie-message').after($prompt); + $prompt.show(); + $prompt.on("click", ".dismiss", function(e) { + $prompt.hide(); + // the warning is dismissable for 2 weeks + setCookie('govuk_browser_upgrade_dismissed', 'yes', 14); + }); + } + } - // We're not showing the message on first visit - setCookie('govuk_not_first_visit', 'yes', 28); + // We're not showing the message on first visit + setCookie('govuk_not_first_visit', 'yes', 28); } }); diff --git a/app/views/root/_base.html.erb b/app/views/root/_base.html.erb index 2fe34ac3b..b7525dd1e 100644 --- a/app/views/root/_base.html.erb +++ b/app/views/root/_base.html.erb @@ -55,9 +55,7 @@GOV.UK uses cookies to make the site simpler. Find out more about cookies
-For a safer, faster, better experience online you should upgrade your browser. Find out more about browsers Close
-