mirror of
https://github.com/nasa/openmct.git
synced 2025-05-06 02:28:21 +00:00
[Common UI] Only show warning for unsupported browsers
This commit is contained in:
parent
a6ceae4045
commit
37890280ae
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"implementation": "UnsupportedBrowserWarning.js",
|
"implementation": "UnsupportedBrowserWarning.js",
|
||||||
"depends": [ "notificationService" ]
|
"depends": [ "notificationService", "agentService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stylesheets": [
|
"stylesheets": [
|
||||||
|
@ -36,7 +36,9 @@ define(
|
|||||||
"This software has been developed and tested",
|
"This software has been developed and tested",
|
||||||
"using the latest Google Chrome,",
|
"using the latest Google Chrome,",
|
||||||
"and may be unstable in other browsers."
|
"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.
|
* Shows a warning if a user's browser is unsupported.
|
||||||
@ -45,11 +47,16 @@ define(
|
|||||||
* @param {NotificationService} notificationService the notification
|
* @param {NotificationService} notificationService the notification
|
||||||
* service
|
* service
|
||||||
*/
|
*/
|
||||||
function UnsupportedBrowserWarning(notificationService) {
|
function UnsupportedBrowserWarning(notificationService, agentService) {
|
||||||
notificationService.alert({
|
var testToBrowser = agentService.isMobile() ?
|
||||||
title: WARNING_TITLE,
|
MOBILE_BROWSER : DESKTOP_BROWSER;
|
||||||
actionText: WARNING_DESCRIPTION
|
|
||||||
});
|
if (!agentService.isBrowser(testToBrowser)) {
|
||||||
|
notificationService.alert({
|
||||||
|
title: WARNING_TITLE,
|
||||||
|
actionText: WARNING_DESCRIPTION
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnsupportedBrowserWarning;
|
return UnsupportedBrowserWarning;
|
||||||
|
@ -43,6 +43,7 @@ define(
|
|||||||
var userAgent = $window.navigator.userAgent,
|
var userAgent = $window.navigator.userAgent,
|
||||||
matches = userAgent.match(/iPad|iPhone|Android/i) || [];
|
matches = userAgent.match(/iPad|iPhone|Android/i) || [];
|
||||||
|
|
||||||
|
this.userAgent = userAgent;
|
||||||
this.mobileName = matches[0];
|
this.mobileName = matches[0];
|
||||||
this.$window = $window;
|
this.$window = $window;
|
||||||
}
|
}
|
||||||
@ -91,6 +92,18 @@ define(
|
|||||||
return !this.isPortrait();
|
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;
|
return AgentService;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user