keeweb/app/scripts/util/feature-detector.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-10-17 23:49:24 +02:00
'use strict';
var FeatureDetector = {
isMac: function() {
return navigator.platform.indexOf('Mac') >= 0;
},
2016-03-31 22:52:04 +02:00
isWindows: function() {
return navigator.platform.indexOf('Win') >= 0;
},
isiOS: function() {
return /(iPad|iPhone)/i.test(navigator.userAgent);
},
2015-11-21 15:55:42 +01:00
isMobile: function() {
return typeof window.orientation !== 'undefined';
},
isDesktop: function() {
return !this.isMobile();
},
2015-10-17 23:49:24 +02:00
actionShortcutSymbol: function(formatting) {
return this.isMac() ? '⌘' : formatting ? '<span class="thin">ctrl + </span>' : 'ctrl-';
},
altShortcutSymbol: function(formatting) {
return this.isMac() ? '⌥' : formatting ? '<span class="thin">alt + </span>' : 'alt-';
2015-10-27 22:57:56 +01:00
},
globalShortcutSymbol: function(formatting) {
return this.isMac() ? '⌃⌥' : formatting ? '<span class="thin">shift+alt+</span>' : 'shift-alt-';
},
globalShortcutIsLarge: function() {
return !this.isMac();
},
2016-03-31 22:52:04 +02:00
screenshotToClipboardShortcut: function() {
if (this.isiOS()) { return 'Sleep+Home'; }
if (this.isMobile()) { return ''; }
if (this.isMac()) { return 'Command-Shift-Control-4'; }
if (this.isWindows()) { return 'Alt+PrintScreen'; }
return '';
},
2015-10-27 22:57:56 +01:00
shouldMoveHiddenInputToCopySource: function() {
2016-03-31 22:52:04 +02:00
return this.isiOS();
2015-10-29 22:13:15 +01:00
},
canCopyReadonlyInput: function() {
return !(/CriOS/i.test(navigator.userAgent));
2016-02-14 08:38:57 +01:00
},
isBeta: function() {
return window.location.href.toLowerCase().indexOf('beta.') > 0;
2015-10-17 23:49:24 +02:00
}
};
module.exports = FeatureDetector;