4958: Detect old browsers and recommend upgrading.
authorTom Clegg <tom@curoverse.com>
Sat, 7 Feb 2015 22:19:50 +0000 (17:19 -0500)
committerTom Clegg <tom@curoverse.com>
Sun, 8 Feb 2015 02:25:47 +0000 (21:25 -0500)
We use a plain .js file in /public instead of the asset pipeline, and
don't rely on any JS libraries. This gives the error alert a much
better chance of working in a browser that can't even parse our
compiled/minified application.js.

apps/workbench/app/views/application/_browser_unsupported.html [new file with mode: 0644]
apps/workbench/app/views/layouts/body.html.erb
apps/workbench/public/browser_unsupported.js [new file with mode: 0644]

diff --git a/apps/workbench/app/views/application/_browser_unsupported.html b/apps/workbench/app/views/application/_browser_unsupported.html
new file mode 100644 (file)
index 0000000..7f180f4
--- /dev/null
@@ -0,0 +1,16 @@
+<!-- googleoff: all -->
+<div id="browser-unsupported" class="hidden">
+  <div class="alert alert-danger">
+    <p>
+      <b>Hey!</b> Your web browser is missing some of the features we
+      rely on.  Usually this means you're running an old version.
+      Updating your system, or switching to a current version
+      of <a class="alert-link"
+      href="//google.com/search?q=download+Mozilla+Firefox">Firefox</a>
+      or <a class="alert-link"
+      href="//google.com/search?q=download+Google+Chrome">Chrome</a>,
+      should fix this.
+    </p>
+  </div>
+</div>
+<!-- googleon: all -->
index fb28efe1d40cb8cdf14b48f926b318c7bc016674..67eba944508df47839bb3fafb0ac4524e7f2e082 100644 (file)
       </nav>
     <% end %>
 
+    <%= render partial: 'browser_unsupported' %><%# requires JS support below %>
+
     <div id="page-wrapper">
       <%= yield %>
     </div>
 
 <div class="modal-container"></div>
 <div id="report-issue-modal-window"></div>
+<script src="/browser_unsupported.js"></script>
diff --git a/apps/workbench/public/browser_unsupported.js b/apps/workbench/public/browser_unsupported.js
new file mode 100644 (file)
index 0000000..77d641c
--- /dev/null
@@ -0,0 +1,13 @@
+(function() {
+    var ok = false;
+    try {
+        if (window.Blob &&
+            window.File &&
+            window.FileReader) {
+            ok = true;
+        }
+    } catch(err) {}
+    if (!ok) {
+        document.getElementById('browser-unsupported').className='';
+    }
+})();