mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:20:57 -06:00
DEV: Add if a user is using an Apple device in widget capabilities (#15021)
* Consolidate device capability sniffing in caps
This commit is contained in:
parent
49c49e8ae0
commit
340901c913
@ -478,9 +478,9 @@ export function inCodeBlock(text, pos) {
|
||||
}
|
||||
|
||||
export function translateModKey(string) {
|
||||
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
||||
// Mac users are used to glyphs for shortcut keys
|
||||
if (mac) {
|
||||
const { isApple } = helperContext().capabilities;
|
||||
// Apple device users are used to glyphs for shortcut keys
|
||||
if (isApple) {
|
||||
string = string
|
||||
.replace("Shift", "\u21E7")
|
||||
.replace("Meta", "\u2318")
|
||||
|
@ -1,4 +1,9 @@
|
||||
// Initializes an object that lets us know about browser's capabilities
|
||||
|
||||
const APPLE_NAVIGATOR_PLATFORMS = /iPhone|iPod|iPad|Macintosh|MacIntel/;
|
||||
|
||||
const APPLE_USERAGENTDATA_PLATFORM = /macOS/;
|
||||
|
||||
export default {
|
||||
name: "sniff-capabilities",
|
||||
|
||||
@ -28,6 +33,11 @@ export default {
|
||||
(/iPhone|iPod/.test(navigator.userAgent) || caps.isIpadOS) &&
|
||||
!window.MSStream;
|
||||
|
||||
caps.isApple =
|
||||
APPLE_NAVIGATOR_PLATFORMS.test(navigator.platform) ||
|
||||
(navigator.userAgentData &&
|
||||
APPLE_USERAGENTDATA_PLATFORM.test(navigator.userAgentData.platform));
|
||||
|
||||
caps.hasContactPicker =
|
||||
"contacts" in navigator && "ContactsManager" in window;
|
||||
caps.canVibrate = "vibrate" in navigator;
|
||||
|
Loading…
Reference in New Issue
Block a user