2016-07-17 21:08:23 +02:00
|
|
|
const MobileRegex = /iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile|WPDesktop|Windows Phone|webOS/i;
|
|
|
|
const MinDesktopScreenWidth = 800;
|
|
|
|
|
2017-05-28 17:30:00 +02:00
|
|
|
const isDesktop = !!(window.process && window.process.versions && window.process.versions.electron);
|
|
|
|
|
2017-01-31 07:50:28 +01:00
|
|
|
const FeatureDetector = {
|
2017-05-28 17:30:00 +02:00
|
|
|
isDesktop: isDesktop,
|
2016-07-17 21:08:23 +02:00
|
|
|
isMac: navigator.platform.indexOf('Mac') >= 0,
|
|
|
|
isWindows: navigator.platform.indexOf('Win') >= 0,
|
|
|
|
isiOS: /iPad|iPhone|iPod/i.test(navigator.userAgent),
|
|
|
|
isMobile: MobileRegex.test(navigator.userAgent) || screen.width < MinDesktopScreenWidth,
|
2019-08-16 23:05:39 +02:00
|
|
|
isPopup: !!(window.parent !== window.top || window.opener),
|
2017-05-16 21:26:42 +02:00
|
|
|
isStandalone: !!navigator.standalone,
|
2017-08-31 18:56:11 +02:00
|
|
|
isFrame: window.top !== window,
|
2017-05-28 17:30:00 +02:00
|
|
|
isSelfHosted: !isDesktop && !/^http(s?):\/\/((localhost:8085)|((app|beta)\.keeweb\.info))/.test(location.href),
|
2017-05-26 19:18:22 +02:00
|
|
|
needFixClicks: /Edge\/14/.test(navigator.appVersion),
|
2016-07-17 21:08:23 +02:00
|
|
|
|
2015-10-17 23:49:24 +02:00
|
|
|
actionShortcutSymbol: function(formatting) {
|
2016-07-17 21:08:23 +02:00
|
|
|
return this.isMac ? '⌘' : formatting ? '<span class="thin">ctrl + </span>' : 'ctrl-';
|
2015-10-17 23:49:24 +02:00
|
|
|
},
|
|
|
|
altShortcutSymbol: function(formatting) {
|
2016-07-17 21:08:23 +02:00
|
|
|
return this.isMac ? '⌥' : formatting ? '<span class="thin">alt + </span>' : 'alt-';
|
2015-10-27 22:57:56 +01:00
|
|
|
},
|
2016-02-28 18:13:23 +01:00
|
|
|
globalShortcutSymbol: function(formatting) {
|
2016-07-17 21:08:23 +02:00
|
|
|
return this.isMac ? '⌃⌥' : formatting ? '<span class="thin">shift+alt+</span>' : 'shift-alt-';
|
2016-02-28 18:13:23 +01:00
|
|
|
},
|
|
|
|
globalShortcutIsLarge: function() {
|
2016-07-17 21:08:23 +02:00
|
|
|
return !this.isMac;
|
2016-02-28 18:13:23 +01:00
|
|
|
},
|
2016-03-31 22:52:04 +02:00
|
|
|
screenshotToClipboardShortcut: function() {
|
2019-08-16 23:05:39 +02:00
|
|
|
if (this.isiOS) {
|
|
|
|
return 'Sleep+Home';
|
|
|
|
}
|
|
|
|
if (this.isMobile) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (this.isMac) {
|
|
|
|
return 'Command-Shift-Control-4';
|
|
|
|
}
|
|
|
|
if (this.isWindows) {
|
|
|
|
return 'Alt+PrintScreen';
|
|
|
|
}
|
2016-03-31 22:52:04 +02:00
|
|
|
return '';
|
|
|
|
},
|
2017-05-14 21:23:49 +02:00
|
|
|
supportsTitleBarStyles: function() {
|
|
|
|
return this.isMac;
|
|
|
|
},
|
|
|
|
hasUnicodeFlags: function() {
|
2017-03-26 16:46:26 +02:00
|
|
|
return this.isMac;
|
2017-05-16 22:56:52 +02:00
|
|
|
},
|
2017-05-25 21:37:04 +02:00
|
|
|
getBrowserCssClass: function() {
|
|
|
|
if (window.chrome && window.chrome.webstore) {
|
|
|
|
return 'chrome';
|
|
|
|
}
|
|
|
|
if (window.navigator.userAgent.indexOf('Edge/') > -1) {
|
|
|
|
return 'edge';
|
|
|
|
}
|
2019-03-28 22:31:53 +01:00
|
|
|
if (navigator.standalone) {
|
|
|
|
return 'standalone';
|
|
|
|
}
|
2017-05-25 21:37:04 +02:00
|
|
|
return '';
|
2015-10-17 23:49:24 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = FeatureDetector;
|