Merge pull request #524 from dgilperez/ie_alert_cookie
Cookie for IE alert
This commit is contained in:
@@ -34,6 +34,7 @@ var initialize_modules = function() {
|
|||||||
App.LocationChanger.initialize();
|
App.LocationChanger.initialize();
|
||||||
App.CheckAllNone.initialize();
|
App.CheckAllNone.initialize();
|
||||||
App.PreventDoubleSubmission.initialize();
|
App.PreventDoubleSubmission.initialize();
|
||||||
|
App.IeAlert.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.Dropdown =
|
App.Dropdown =
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
$(document).foundation();
|
$(document).foundation()
|
||||||
|
|||||||
9
app/assets/javascripts/ie_alert.js.coffee
Normal file
9
app/assets/javascripts/ie_alert.js.coffee
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
App.IeAlert =
|
||||||
|
set_cookie_and_hide: (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
$.cookie('ie_alert_closed', 'true', { path: '/', expires: 365 });
|
||||||
|
$('.ie-alert-box').remove()
|
||||||
|
|
||||||
|
initialize: ->
|
||||||
|
$('.ie-alert-box-close-js').on 'click', (event) ->
|
||||||
|
App.IeAlert.set_cookie_and_hide(event)
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
<%= render 'layouts/header' %>
|
<%= render 'layouts/header' %>
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<% if browser.ie? %>
|
<% if browser.ie? && cookies['ie_alert_closed'] != 'true' %>
|
||||||
<div data-alert class="alert-box info ie-alert-box">
|
<div data-alert class="alert-box info ie-alert-box">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close ie-alert-box-close-js">×</a>
|
||||||
<h2><%= t("layouts.application.ie_title") %></h2>
|
<h2><%= t("layouts.application.ie_title") %></h2>
|
||||||
<p>
|
<p>
|
||||||
<%= t("layouts.application.ie",
|
<%= t("layouts.application.ie",
|
||||||
|
|||||||
@@ -19,4 +19,31 @@ feature "Home" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature 'IE alert' do
|
||||||
|
scenario 'IE visitors are presented with an alert until they close it', :js do
|
||||||
|
page.driver.headers = { "User-Agent" => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" }
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
expect(page).to have_xpath(ie_alert_box_xpath, visible: false)
|
||||||
|
expect(page.driver.cookies['ie_alert_closed']).to be_nil
|
||||||
|
|
||||||
|
# faking close button, since a normal find and click
|
||||||
|
# will not work as the element is inside a HTML conditional comment
|
||||||
|
page.driver.set_cookie 'ie_alert_closed', 'true'
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||||
|
expect(page.driver.cookies["ie_alert_closed"].value).to eq('true')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'non-IE visitors are not bothered with IE alerts', :js do
|
||||||
|
visit root_path
|
||||||
|
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||||
|
expect(page.driver.cookies['ie_alert_closed']).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def ie_alert_box_xpath
|
||||||
|
"/html/body/div[@class='wrapper']/comment()[contains(.,'ie-alert-box')]"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user