Prettified all files.

This commit is contained in:
2019-07-18 12:26:39 +02:00
parent 7744b92771
commit 2d400a18ec
125 changed files with 11184 additions and 8154 deletions
+40 -19
View File
@@ -1,7 +1,6 @@
/** Report capabilities with guaranteed values.
*/
export class Capabilities {
/** Returns the browser userAgent.
@return {string}
*/
@@ -14,7 +13,7 @@ export class Capabilities {
@return {boolean}
*/
static get isMobile() {
return (/Mobi/.test(navigator.userAgent))
return /Mobi/.test(navigator.userAgent)
}
/** Tests whether the app is running on a iOS device.
@@ -22,7 +21,7 @@ export class Capabilities {
@return {boolean}
*/
static get isIOS() {
return (/iPad|iPhone|iPod/.test(navigator.userAgent)) && !window.MSStream
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
}
/** Tests whether the app is running in a Safari environment.
@@ -31,28 +30,44 @@ export class Capabilities {
@return {boolean}
*/
static get isSafari() {
return navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && navigator.userAgent && !navigator.userAgent.match('CriOS')
return (
navigator.vendor &&
navigator.vendor.indexOf('Apple') > -1 &&
navigator.userAgent &&
!navigator.userAgent.match('CriOS')
)
}
/**
* Distincts if the app is running inside electron or not.
*
*
* source: https://github.com/cheton/is-electron
*/
static get isElectron() {
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
if (
typeof window !== 'undefined' &&
typeof window.process === 'object' &&
window.process.type === 'renderer'
) {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
if (
typeof process !== 'undefined' &&
typeof process.versions === 'object' &&
!!process.versions.electron
) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
if (
typeof navigator === 'object' &&
typeof navigator.userAgent === 'string' &&
navigator.userAgent.indexOf('Electron') >= 0
) {
return true
}
@@ -70,52 +85,56 @@ export class Capabilities {
@return {boolean}
*/
static get isMultiTouchTable() {
return Capabilities.devicePixelRatio > 2 && Capabilities.isMobile === false && /Windows/i.test(Capabilities.userAgent)
return (
Capabilities.devicePixelRatio > 2 &&
Capabilities.isMobile === false &&
/Windows/i.test(Capabilities.userAgent)
)
}
/** Returns true if mouse events are supported
@return {boolean}
*/
static supportsMouseEvents() {
return typeof(window.MouseEvent) != 'undefined'
return typeof window.MouseEvent != 'undefined'
}
/** Returns true if touch events are supported
@return {boolean}
*/
static supportsTouchEvents() {
return typeof(window.TouchEvent) != 'undefined'
return typeof window.TouchEvent != 'undefined'
}
/** Returns true if pointer events are supported
@return {boolean}
*/
static supportsPointerEvents() {
return typeof(window.PointerEvent) != 'undefined'
return typeof window.PointerEvent != 'undefined'
}
/** Returns true if DOM templates are supported
@return {boolean}
*/
static supportsTemplate() {
return 'content' in document.createElement('template');
return 'content' in document.createElement('template')
}
}
/** Basic tests for Capabilities.
*/
export class CapabilitiesTests {
static testConfirm() {
let bool = confirm('Please confirm')
document.getElementById('demo').innerHTML = (bool) ? 'Confirmed' : 'Not confirmed'
document.getElementById('demo').innerHTML = bool
? 'Confirmed'
: 'Not confirmed'
}
static testPrompt() {
let person = prompt('Please enter your name', 'Harry Potter')
if (person != null) {
demo.innerHTML =
'Hello ' + person + '! How are you today?'
demo.innerHTML = 'Hello ' + person + '! How are you today?'
}
}
@@ -130,7 +149,9 @@ export class CapabilitiesTests {
}
static testMultiTouchTable() {
let value = 'Is the device a multi-touch table? ' + Capabilities.isMultiTouchTable
let value =
'Is the device a multi-touch table? ' +
Capabilities.isMultiTouchTable
multi_touch_table.innerHTML = value
}