@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
75 lines • 3 kB
JavaScript
export var Environment = {
//#region browser & hardware
IsIos: function () {
return (/iPad|iPhone|iPod/.test(navigator.platform) ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
!window.MSStream;
},
GetIosVersion: function () {
if (navigator.appVersion == null || !Environment.IsIos())
return [];
var match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
if (match == null)
return [];
return match.slice(1)
.map(function (v) { return parseInt(v, 10); })
.map(function (n) { return isNaN(n) ? null : n; });
},
IosMajorVersion: function () {
var ua = navigator.userAgent;
var uaIndex = ua.indexOf("OS ");
if (uaIndex > -1)
return Number(ua.substr(uaIndex + 3, 3).replace("_", ".").charAt(0));
},
IsAndroid: function () {
return !!navigator.userAgent.toLowerCase().match(/(android)/);
},
IsTouchDevice: function () {
return Environment.IsIos() || Environment.IsAndroid() || Environment.IsTouchIE();
},
IsNativeAndroidBrowser: function () {
var nua = navigator.userAgent;
return ((nua.indexOf("Mozilla/5.0") > -1 && nua.indexOf("Android ") > -1 && nua.indexOf("AppleWebKit") > -1) && !(nua.indexOf("Chrome") > -1));
},
IsGoogleChrome: function () {
return typeof window["chrome"] == "object";
},
IsSafari: function () {
return navigator.userAgent.indexOf("Safari") !== -1 && navigator.userAgent.indexOf("Chrome") === -1;
},
IsSafariOrSafariWebView: function () {
return Environment.IsSafari() || Environment.IsIos();
},
IsFirefox: function () {
return navigator.userAgent.indexOf("Firefox") !== -1 && navigator.userAgent.indexOf("Seamonkey") === -1;
},
IsTouchIE: function () {
return navigator.userAgent.indexOf("Trident") !== -1 && navigator.userAgent.indexOf("Touch") !== -1;
},
IsIE: function () {
return navigator.userAgent.indexOf("MSIE") !== -1 || navigator.appVersion.indexOf("Trident/") > 0;
},
IsEdge: function () {
return navigator.userAgent.indexOf("Edge") != -1;
},
GetEdgeHtmlVersion: function () {
if (!Environment.IsEdge())
return [];
return navigator.userAgent.match(/Edge\/(\d+).(\d+)/)
.slice(1)
.map(function (v) { return parseInt(v, 10); })
.map(function (n) { return isNaN(n) ? null : n; });
},
//#endregion
get devicePixelRatio() {
return window.devicePixelRatio != null ? window.devicePixelRatio : 1;
},
get screenDpi() {
return 96 * Environment.devicePixelRatio;
},
IsSmallScreen: function () {
return window.innerWidth <= 500;
}
};
export default Environment;
//# sourceMappingURL=Environment.js.map