new Device()
Manage Devices inside FORGE.
Device is singleton, so if you have multiple instances in the same page you MUST avoid UID conflict.
Device is singleton, so if you have multiple instances in the same page you MUST avoid UID conflict.
- Source:
Extends
Members
(readonly) addEventListener :boolean
Is native support of addEventListener available?
Type:
- boolean
- Source:
(readonly) alive :boolean
Get the alive flag value of the object.
Type:
- boolean
- Inherited From:
- Source:
(readonly) android :boolean
Is running on android?
Type:
- boolean
- Source:
(readonly) androidStockBrowserVersion :number
The Android version linked to the stock browser.
Type:
- number
- Source:
(readonly) applicationCache :boolean
Is Application Cache supported to enable web-based applications run offline?
Type:
- boolean
- Source:
(readonly) audioTag :boolean
Are Audio tags available?
Type:
- boolean
- Source:
(readonly) battery :boolean
Is the Battery API available?
Type:
- boolean
- Source:
(readonly) browser :string
The nick name of the browser.
Type:
- string
- Source:
(readonly) browserVersion :number
The browser major version.
Type:
- number
- Source:
(readonly) canvasText :boolean
Is text API for canvas available?
Type:
- boolean
- Source:
(readonly) canvasWinding :boolean
Are winding rules for '
Type:
- boolean
- Source:
(readonly) chromeOS :boolean
Is running on chromeOS?
Type:
- boolean
- Source:
(readonly) chromeVersion :number
Chrome major version number.
Type:
- number
- Source:
(readonly) className :string
Get the class name of the object.
Type:
- string
- Inherited From:
- Source:
(readonly) contextMenu :boolean
Is context menu available?
Type:
- boolean
- Source:
(readonly) cssAnimation :boolean
Are css animations (keyframes) supported?
Type:
- boolean
- Source:
(readonly) cssPointerEvents :boolean
Is pointer-events available?
Type:
- boolean
- Source:
(readonly) cssRgba :boolean
Is rgba (alpha) available?
Type:
- boolean
- Source:
data :*
Get and set any custom data you want to associate to this object.
Type:
- *
- Inherited From:
- Source:
debug :boolean
Get and set the debug flag.
Type:
- boolean
- Inherited From:
- Source:
(readonly) desktop :boolean
Is running on a desktop?
Type:
- boolean
- Source:
(readonly) deviceMotion :boolean
Is Device Motion Event supported? (Accelerometer)
Type:
- boolean
- Source:
(readonly) deviceMotionAcceleration :boolean
Is Device Motion acceleration supported?
Type:
- boolean
- Source:
(readonly) deviceMotionRotationRate :boolean
Is Device Motion rotation supported?
Type:
- boolean
- Source:
(readonly) deviceOrientation :boolean
Is Device Orientation Event supported? (Magnetometer)
Type:
- boolean
- Source:
(readonly) deviceOrientationMagnetometer :boolean
Is Device Orientation motion supported?
Type:
- boolean
- Source:
(readonly) dpi :number
Pixel density of the screen.
Type:
- number
- Source:
(readonly) edgeVersion :number
Edge major version number.
Type:
- number
- Source:
(readonly) encryptedMedia :boolean
Is Encrypted Media Extensions API available?
Type:
- boolean
- Source:
(readonly) exitFullscreen :string
Exit full screen method name.
Type:
- string
- Source:
(readonly) fileSystem :boolean
Is fileSystem available?
Type:
- boolean
- Source:
(readonly) firefox :boolean
Is running in Firefox?
Type:
- boolean
- Source:
(readonly) firefoxVersion :number
Firefox major version number.
Type:
- number
- Source:
(readonly) fullscreenElement :string
fullscreenElement accessor name.
Type:
- string
- Source:
(readonly) fullscreenEnabled :string
Does the browser support full screen API?
Type:
- string
- Source:
(readonly) fullscreenKeyboard :boolean
Does the browser support keyboard during full screen mode?
Type:
- boolean
- Source:
(readonly) gamepad :boolean
Is Gamepad API available?
Type:
- boolean
- Source:
(readonly) geolocation :boolean
Is Geolocation API available?
Type:
- boolean
- Source:
(readonly) gyroscope :boolean
Device has a real gyroscope?
Type:
- boolean
- Source:
(readonly) h264Video :boolean
Can play h264 video files?
Type:
- boolean
- Source:
(readonly) history :boolean
Is History API available?
Type:
- boolean
- Source:
(readonly) hlsVideo :boolean
Can play hls video files?
Type:
- boolean
- Source:
(readonly) ie :boolean
Is running in Internet Explorer?
Type:
- boolean
- Source:
(readonly) ieVersion :number
Internet Explorer major version number.
Type:
- number
- Source:
(readonly) isAndroidStockBrowser :boolean
Detect if it's an Android Stock browser.
Type:
- boolean
- Source:
(readonly) isIframe :boolean
Is the current page is into an Iframe ?
Type:
- boolean
- Source:
(readonly) isSecure :boolean
Is the current page in secure mode?
Type:
- boolean
- Source:
(readonly) JSON :boolean
Is JSON native support available?
Type:
- boolean
- Source:
(readonly) localStorage :boolean
Is localStorage available?
Type:
- boolean
- Source:
(readonly) lockOrientation :string
Lock screen orientation method name.
Type:
- string
- Source:
(readonly) mediaSource :boolean
Is Media Source Extensions API available?
Type:
- boolean
- Source:
(readonly) mobile :boolean
Is running on a mobile?
Type:
- boolean
- Source:
(readonly) mp4Video :boolean
Can play mp4 video files?
Type:
- boolean
- Source:
(readonly) oggVideo :boolean
Can play ogg video files?
Type:
- boolean
- Source:
(readonly) onDestroy :FORGE.EventDispatcher
Get the onDestroy FORGE.EventDispatcher, this event is emitted at the end of the destroy sequence.
Type:
- Inherited From:
- Source:
(readonly) operaVersion :number
Opera major version number.
Type:
- number
- Source:
(readonly) orientation :string
Screen orientation object name.
Type:
- string
- Source:
(readonly) osVersion :number
The OS major version number.
Type:
- number
- Source:
(readonly) other :boolean
Is running on a other device as smartTv...?
Type:
- boolean
- Source:
(readonly) pixelRatio :number
Pixel ratio of the device.
Type:
- number
- Source:
(readonly) pointerLock :boolean
Is pointerLock available?
Type:
- boolean
- Source:
(readonly) quirksMode :boolean
Is the browser running in strict mode or quirks mode?
Type:
- boolean
- Source:
(readonly) ready :boolean
Is device detection done?
Type:
- boolean
- Source:
(readonly) requestFullscreen :string
Request full screen method name.
Type:
- string
- Source:
(readonly) retina :boolean
Is running on Apple Retina display?
Type:
- boolean
- Source:
(readonly) safariVersion :number
Safari (or Mobile Safari) major version number.
Type:
- number
- Source:
(readonly) screenHeight :number
Device screen height in pixels.
Type:
- number
- Source:
(readonly) screenOrientation :boolean
Is screen orienation API available?
Type:
- boolean
- Source:
(readonly) screenWidth :number
Device screen width in pixels.
Type:
- number
- Source:
(readonly) silk :boolean
Is running in Silk (Kindle)?
Type:
- boolean
- Source:
(readonly) tablet :boolean
Is running on a tablet?
Type:
- boolean
- Source:
(readonly) tags :Array
Get the tags associated to this object.
Type:
- Array
- Inherited From:
- Source:
(readonly) touchForce :boolean
Are Force Touch Events supported?
Force Touch events are available in OS X 10.11 and later on devices equipped with Force Touch trackpads.
Type:
- boolean
- Source:
(readonly) uid :string
Get the uid of the object.
Type:
- string
- Inherited From:
- Source:
(readonly) unlockOrientation :string
Unlock screen orientation method name.
Type:
- string
- Source:
(readonly) vibrate :boolean
Does the device support the Vibration API?
Type:
- boolean
- Source:
(readonly) visibilityChange :string
Visibility change event name for the PageVisibility API.
Type:
- string
- Source:
(readonly) visibilityState :string
Hidden state name for the PageVisibility API.
Type:
- string
- Source:
(readonly) vp9Video :boolean
Can play vp9 video files?
Type:
- boolean
- Source:
warning :boolean
Get and set the warning flag.
Type:
- boolean
- Inherited From:
- Source:
(readonly) webApp :boolean
Is running in a standalone app?
Type:
- boolean
- Source:
(readonly) webAudio :boolean
Is the WebAudio API available?
Type:
- boolean
- Source:
(readonly) webmVideo :boolean
Can play webm video files?
Type:
- boolean
- Source:
(readonly) windows :boolean
Is running on Windows?
Type:
- boolean
- Source:
(readonly) windowsPhone :boolean
Is running on Windows Phone?
Type:
- boolean
- Source:
Methods
(static) check(config, deviceopt, conditionopt) → {boolean}
Check device requirement for an object from configuration/manifest.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
config |
Object | The device requirement configuration of the configuration/manifest. | ||
device |
Object |
<optional> |
FORGE.Device | The device environment to test. The default is FORGE.Device detection, but we need to modify it in test suites. |
condition |
string |
<optional> |
"and" | [description] |
- Source:
Returns:
Returns true if the object is compatible with the device environment, false if not.
- Type
- boolean
(static) checkValue(config, device) → {boolean}
Check a single device config for the main check method
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | boolean | number | string | The configuration to check |
device |
boolean | number | string | The device value |
- Source:
Returns:
- Type
- boolean
canPlayAudio(type) → {boolean}
Check if the device can play audio.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'. |
- Source:
Returns:
- Type
- boolean
canPlayVideo(type) → {boolean}
Check If the device can play video files.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | One of 'mp4, 'ogg', 'webm' or 'mpeg'. |
- Source:
Returns:
- Type
- boolean
destroy()
Basic destroy method, prevent double destroy, change the alive flag.
- Inherited From:
- Source:
isLowBattery() → {Promise.<boolean>}
Check If the battery is low.
Note "low" is defined as less than 20%.
Note "low" is defined as less than 20%.
- Source:
Returns:
- Type
- Promise.<boolean>
log(value)
Basic log method, log a string in the console if debug is enabled.
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value you want to log in the console. |
- Inherited From:
- Source:
warn(valuenullable)
Basic warn method, log a warn string in the console if warning is enabled.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | Object |
<nullable> |
The value you want to warn in the console. |
- Inherited From:
- Source: