Skip to content

Commit

Permalink
Merge pull request #317 from alphagov/progressively-enhance-browser-w…
Browse files Browse the repository at this point in the history
…arning

Progressively enhance browser warning
  • Loading branch information
KushalP committed Aug 30, 2013
2 parents 671245e + 39bdbc7 commit 3d1a0fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
47 changes: 30 additions & 17 deletions app/assets/javascripts/browser-check.js
Original file line number Diff line number Diff line change
@@ -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 = $('<div id="global-browser-prompt"></div>'),
text = $('<p>For a safer, faster, better experience online you should upgrade your browser.</p>'),
findMoreLink = $('<a href="/support/browsers">Find out more about browsers</a>'),
closeLink = $('<a href="#" class="dismiss" title="Dismiss this message">Close</a>');

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);
}
});
4 changes: 1 addition & 3 deletions app/views/root/_base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
<p>GOV.UK uses cookies to make the site simpler. <a href="/support/cookies">Find out more about cookies</a></p>
</div>

<div id="global-browser-prompt">
<p>For a safer, faster, better experience online you should upgrade your browser. <a href="/support/browsers">Find out more about browsers</a> <a href="#" class="dismiss" title="Dismiss this message">Close</a></p>
</div>
<% # the browser warning has moved to Javascript. If you want it to appear somewhere else, please modify the Javascript. %>
<section id="user-satisfaction-survey">
<div class="wrapper">
Expand Down

0 comments on commit 3d1a0fd

Please sign in to comment.