From 37890280aeb3d34106869c3cb15c017099af949a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 4 Dec 2015 14:08:42 -0800 Subject: [PATCH] [Common UI] Only show warning for unsupported browsers --- platform/commonUI/general/bundle.json | 2 +- .../general/src/UnsupportedBrowserWarning.js | 19 +++++++++++++------ platform/commonUI/mobile/src/AgentService.js | 13 +++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index dc4d844bc7..76814df12a 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -22,7 +22,7 @@ }, { "implementation": "UnsupportedBrowserWarning.js", - "depends": [ "notificationService" ] + "depends": [ "notificationService", "agentService" ] } ], "stylesheets": [ diff --git a/platform/commonUI/general/src/UnsupportedBrowserWarning.js b/platform/commonUI/general/src/UnsupportedBrowserWarning.js index a131f8c973..f2fa0c3f20 100644 --- a/platform/commonUI/general/src/UnsupportedBrowserWarning.js +++ b/platform/commonUI/general/src/UnsupportedBrowserWarning.js @@ -36,7 +36,9 @@ define( "This software has been developed and tested", "using the latest Google Chrome,", "and may be unstable in other browsers." - ].join(" "); + ].join(" "), + MOBILE_BROWSER = "Safari", + DESKTOP_BROWSER = "Chrome"; /** * Shows a warning if a user's browser is unsupported. @@ -45,11 +47,16 @@ define( * @param {NotificationService} notificationService the notification * service */ - function UnsupportedBrowserWarning(notificationService) { - notificationService.alert({ - title: WARNING_TITLE, - actionText: WARNING_DESCRIPTION - }); + function UnsupportedBrowserWarning(notificationService, agentService) { + var testToBrowser = agentService.isMobile() ? + MOBILE_BROWSER : DESKTOP_BROWSER; + + if (!agentService.isBrowser(testToBrowser)) { + notificationService.alert({ + title: WARNING_TITLE, + actionText: WARNING_DESCRIPTION + }); + } } return UnsupportedBrowserWarning; diff --git a/platform/commonUI/mobile/src/AgentService.js b/platform/commonUI/mobile/src/AgentService.js index 26bb173ee7..109520d8bd 100644 --- a/platform/commonUI/mobile/src/AgentService.js +++ b/platform/commonUI/mobile/src/AgentService.js @@ -43,6 +43,7 @@ define( var userAgent = $window.navigator.userAgent, matches = userAgent.match(/iPad|iPhone|Android/i) || []; + this.userAgent = userAgent; this.mobileName = matches[0]; this.$window = $window; } @@ -91,6 +92,18 @@ define( return !this.isPortrait(); }; + /** + * Check if the user agent matches a certain named device, + * as indicated by checking for a case-insensitive substring + * match. + * @param {string} name the name to check for + * @returns {boolean} true if the user agent includes that name + */ + AgentService.prototype.isBrowser = function (name) { + name = name.toLowerCase(); + return this.userAgent.toLowerCase().indexOf(name) !== -1; + }; + return AgentService; } );