@ui5/webcomponents-base 0.0.0-e7dd012d7 → 0.0.0-e818f286e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/.eslintignore +3 -0
  2. package/CHANGELOG.md +314 -0
  3. package/README.md +53 -7
  4. package/bundle.esm.js +20 -20
  5. package/dist/AssetRegistry.js +8 -9
  6. package/dist/Boot.js +59 -0
  7. package/dist/CSP.js +59 -0
  8. package/dist/CustomElementsRegistry.js +60 -4
  9. package/dist/CustomElementsScope.js +20 -98
  10. package/dist/CustomElementsScopeUtils.js +108 -0
  11. package/dist/DOMObserver.js +65 -0
  12. package/dist/Device.js +71 -773
  13. package/dist/EventProvider.js +30 -26
  14. package/dist/FeaturesRegistry.js +4 -1
  15. package/dist/FontFace.js +7 -95
  16. package/dist/InitialConfiguration.js +37 -21
  17. package/dist/Keys.js +98 -0
  18. package/dist/ManagedStyles.js +83 -0
  19. package/dist/MediaRange.js +109 -0
  20. package/dist/{util/parseProperties.js → PropertiesFileFormat.js} +6 -0
  21. package/dist/Render.js +175 -0
  22. package/dist/RenderScheduler.js +16 -138
  23. package/dist/Runtimes.js +107 -0
  24. package/dist/StaticArea.js +1 -29
  25. package/dist/StaticAreaItem.js +58 -65
  26. package/dist/SystemCSSVars.js +4 -25
  27. package/dist/UI5Element.js +315 -382
  28. package/dist/UI5ElementMetadata.js +132 -17
  29. package/dist/asset-registries/Icons.js +117 -14
  30. package/dist/asset-registries/Illustrations.js +30 -0
  31. package/dist/asset-registries/LocaleData.js +97 -68
  32. package/dist/asset-registries/Themes.js +29 -35
  33. package/dist/asset-registries/i18n.js +62 -49
  34. package/dist/assets/bundle.esm.81ba431e.js +43 -0
  35. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  36. package/dist/config/Icons.js +52 -0
  37. package/dist/config/Language.js +18 -20
  38. package/dist/config/Theme.js +25 -0
  39. package/dist/css/BusyIndicator.css +80 -0
  40. package/dist/css/FontFace.css +75 -0
  41. package/dist/css/OverrideFontFace.css +32 -0
  42. package/dist/css/SystemCSSVars.css +17 -0
  43. package/dist/delegate/ItemNavigation.js +238 -201
  44. package/dist/delegate/ResizeHandler.js +78 -37
  45. package/dist/delegate/ScrollEnablement.js +49 -20
  46. package/dist/features/F6Navigation.js +110 -0
  47. package/dist/features/OpenUI5Enablement.js +119 -0
  48. package/dist/features/OpenUI5Support.js +41 -6
  49. package/dist/generated/AssetParameters.js +1 -1
  50. package/dist/generated/VersionInfo.js +10 -0
  51. package/dist/generated/css/BusyIndicator.css.js +5 -0
  52. package/dist/generated/css/FontFace.css.js +5 -0
  53. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  54. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  55. package/dist/i18nBundle.js +38 -4
  56. package/dist/locale/applyDirection.js +6 -4
  57. package/dist/locale/directionChange.js +32 -0
  58. package/dist/locale/getEffectiveDir.js +28 -0
  59. package/dist/locale/languageChange.js +1 -1
  60. package/dist/renderer/LitRenderer.js +39 -18
  61. package/dist/renderer/directives/style-map.js +72 -0
  62. package/dist/renderer/executeTemplate.js +19 -2
  63. package/dist/sap/base/Log.js +241 -0
  64. package/dist/sap/base/assert.js +8 -0
  65. package/dist/sap/base/security/URLListValidator.js +148 -0
  66. package/dist/sap/base/security/encodeCSS.js +14 -0
  67. package/dist/sap/base/security/encodeXML.js +23 -0
  68. package/dist/sap/base/security/sanitizeHTML.js +16 -0
  69. package/dist/sap/base/strings/toHex.js +8 -0
  70. package/dist/sap/base/util/now.js +7 -0
  71. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +3585 -0
  72. package/dist/theming/CustomStyle.js +25 -5
  73. package/dist/theming/applyTheme.js +11 -16
  74. package/dist/theming/getConstructableStyle.js +7 -6
  75. package/dist/theming/getEffectiveLinksHrefs.js +27 -0
  76. package/dist/theming/getEffectiveStyle.js +24 -8
  77. package/dist/theming/getStylesString.js +4 -2
  78. package/dist/theming/getThemeDesignerTheme.js +25 -5
  79. package/dist/theming/preloadLinks.js +23 -0
  80. package/dist/types/CSSColor.js +9 -0
  81. package/dist/types/CalendarType.js +1 -1
  82. package/dist/types/DataType.js +13 -1
  83. package/dist/types/Float.js +4 -0
  84. package/dist/types/Integer.js +4 -0
  85. package/dist/types/InvisibleMessageMode.js +30 -0
  86. package/dist/types/ItemNavigationBehavior.js +2 -7
  87. package/dist/types/PopupState.js +1 -1
  88. package/dist/types/ValueState.js +1 -1
  89. package/dist/updateShadowRoot.js +29 -0
  90. package/dist/util/AriaLabelHelper.js +6 -8
  91. package/dist/util/Caret.js +32 -0
  92. package/dist/util/ColorConversion.js +398 -0
  93. package/dist/util/FocusableElements.js +22 -9
  94. package/dist/util/HTMLSanitizer.js +7 -0
  95. package/dist/util/InvisibleMessage.js +69 -0
  96. package/dist/util/PopupUtils.js +93 -0
  97. package/dist/util/SlotsHelper.js +43 -0
  98. package/dist/util/TabbableElements.js +5 -1
  99. package/dist/util/arraysAreEqual.js +15 -0
  100. package/dist/util/clamp.js +12 -0
  101. package/dist/util/createLinkInHead.js +19 -0
  102. package/dist/util/debounce.js +17 -0
  103. package/dist/util/escapeRegex.js +10 -0
  104. package/dist/util/generateHighlightedMarkup.js +42 -0
  105. package/dist/util/getActiveElement.js +11 -0
  106. package/dist/util/getClassCopy.js +10 -0
  107. package/dist/util/getEffectiveContentDensity.js +5 -0
  108. package/dist/util/getNormalizedTarget.js +16 -0
  109. package/dist/util/isDefaultSlotProvided.js +11 -0
  110. package/dist/util/isElementInView.js +15 -0
  111. package/dist/util/isNodeHidden.js +1 -1
  112. package/dist/util/isNodeTabbable.js +4 -4
  113. package/hash.txt +1 -0
  114. package/index.js +1 -1
  115. package/lib/generate-asset-parameters/index.js +8 -5
  116. package/lib/generate-styles/index.js +26 -0
  117. package/lib/generate-version-info/index.js +32 -0
  118. package/package-scripts.js +37 -28
  119. package/package.json +20 -13
  120. package/src/AssetRegistry.js +8 -9
  121. package/src/Boot.js +59 -0
  122. package/src/CSP.js +59 -0
  123. package/src/CustomElementsRegistry.js +60 -4
  124. package/src/CustomElementsScope.js +20 -98
  125. package/src/CustomElementsScopeUtils.js +108 -0
  126. package/src/DOMObserver.js +65 -0
  127. package/src/Device.js +71 -773
  128. package/src/EventProvider.js +30 -26
  129. package/src/FeaturesRegistry.js +4 -1
  130. package/src/FontFace.js +7 -95
  131. package/src/InitialConfiguration.js +37 -21
  132. package/src/Keys.js +98 -0
  133. package/src/ManagedStyles.js +83 -0
  134. package/src/MediaRange.js +109 -0
  135. package/src/{util/parseProperties.js → PropertiesFileFormat.js} +6 -0
  136. package/src/Render.js +175 -0
  137. package/src/RenderScheduler.js +16 -138
  138. package/src/Runtimes.js +107 -0
  139. package/src/StaticArea.js +1 -29
  140. package/src/StaticAreaItem.js +58 -65
  141. package/src/SystemCSSVars.js +4 -25
  142. package/src/UI5Element.js +315 -382
  143. package/src/UI5ElementMetadata.js +132 -17
  144. package/src/asset-registries/Icons.js +117 -14
  145. package/src/asset-registries/Illustrations.js +30 -0
  146. package/src/asset-registries/LocaleData.js +97 -68
  147. package/src/asset-registries/Themes.js +29 -35
  148. package/src/asset-registries/i18n.js +62 -49
  149. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  150. package/src/config/Icons.js +52 -0
  151. package/src/config/Language.js +18 -20
  152. package/src/config/Theme.js +25 -0
  153. package/src/css/BusyIndicator.css +80 -0
  154. package/src/css/FontFace.css +75 -0
  155. package/src/css/OverrideFontFace.css +32 -0
  156. package/src/css/SystemCSSVars.css +17 -0
  157. package/src/delegate/ItemNavigation.js +238 -201
  158. package/src/delegate/ResizeHandler.js +78 -37
  159. package/src/delegate/ScrollEnablement.js +49 -20
  160. package/src/features/F6Navigation.js +110 -0
  161. package/src/features/OpenUI5Enablement.js +119 -0
  162. package/src/features/OpenUI5Support.js +41 -6
  163. package/src/i18nBundle.js +38 -4
  164. package/src/locale/applyDirection.js +6 -4
  165. package/src/locale/directionChange.js +32 -0
  166. package/src/locale/getEffectiveDir.js +28 -0
  167. package/src/locale/languageChange.js +1 -1
  168. package/src/renderer/LitRenderer.js +39 -18
  169. package/src/renderer/directives/style-map.js +72 -0
  170. package/src/renderer/executeTemplate.js +19 -2
  171. package/src/theming/CustomStyle.js +25 -5
  172. package/src/theming/applyTheme.js +11 -16
  173. package/src/theming/getConstructableStyle.js +7 -6
  174. package/src/theming/getEffectiveLinksHrefs.js +27 -0
  175. package/src/theming/getEffectiveStyle.js +24 -8
  176. package/src/theming/getStylesString.js +4 -2
  177. package/src/theming/getThemeDesignerTheme.js +25 -5
  178. package/src/theming/preloadLinks.js +23 -0
  179. package/src/types/CSSColor.js +9 -0
  180. package/src/types/CalendarType.js +1 -1
  181. package/src/types/DataType.js +13 -1
  182. package/src/types/Float.js +4 -0
  183. package/src/types/Integer.js +4 -0
  184. package/src/types/InvisibleMessageMode.js +30 -0
  185. package/src/types/ItemNavigationBehavior.js +2 -7
  186. package/src/types/PopupState.js +1 -1
  187. package/src/types/ValueState.js +1 -1
  188. package/src/updateShadowRoot.js +29 -0
  189. package/src/util/AriaLabelHelper.js +6 -8
  190. package/src/util/Caret.js +32 -0
  191. package/src/util/ColorConversion.js +398 -0
  192. package/src/util/FocusableElements.js +22 -9
  193. package/src/util/HTMLSanitizer.js +7 -0
  194. package/src/util/InvisibleMessage.js +69 -0
  195. package/src/util/PopupUtils.js +93 -0
  196. package/src/util/SlotsHelper.js +43 -0
  197. package/src/util/TabbableElements.js +5 -1
  198. package/src/util/arraysAreEqual.js +15 -0
  199. package/src/util/clamp.js +12 -0
  200. package/src/util/createLinkInHead.js +19 -0
  201. package/src/util/debounce.js +17 -0
  202. package/src/util/escapeRegex.js +10 -0
  203. package/src/util/generateHighlightedMarkup.js +42 -0
  204. package/src/util/getActiveElement.js +11 -0
  205. package/src/util/getClassCopy.js +10 -0
  206. package/src/util/getEffectiveContentDensity.js +5 -0
  207. package/src/util/getNormalizedTarget.js +16 -0
  208. package/src/util/isDefaultSlotProvided.js +11 -0
  209. package/src/util/isElementInView.js +15 -0
  210. package/src/util/isNodeHidden.js +1 -1
  211. package/src/util/isNodeTabbable.js +4 -4
  212. package/used-modules.txt +10 -0
  213. package/bundle.es5.js +0 -28
  214. package/config/.eslintrc.js +0 -3
  215. package/config/rollup.config.js +0 -1
  216. package/dist/SVGIconRegistry.js +0 -73
  217. package/dist/boot.js +0 -34
  218. package/dist/compatibility/DOMObserver.js +0 -62
  219. package/dist/compatibility/patchNodeValue.js +0 -24
  220. package/dist/compatibility/whenPolyfillLoaded.js +0 -26
  221. package/dist/config/AssetsPath.js +0 -17
  222. package/dist/delegate/CustomResize.js +0 -78
  223. package/dist/delegate/NativeResize.js +0 -45
  224. package/dist/features/PropertiesFormatSupport.js +0 -8
  225. package/dist/features/browsersupport/Edge.js +0 -6
  226. package/dist/features/browsersupport/IE11.js +0 -42
  227. package/dist/features/browsersupport/IE11WithWebComponentsPolyfill.js +0 -5
  228. package/dist/renderer/ifDefined.js +0 -21
  229. package/dist/renderer/scopeHTML.js +0 -32
  230. package/dist/resources/bundle.es5.js +0 -212
  231. package/dist/resources/bundle.es5.js.map +0 -1
  232. package/dist/resources/bundle.esm.js +0 -129
  233. package/dist/resources/bundle.esm.js.map +0 -1
  234. package/dist/test-resources/assets/Themes.js +0 -17
  235. package/dist/test-resources/elements/Child.js +0 -35
  236. package/dist/test-resources/elements/Generic.js +0 -84
  237. package/dist/test-resources/elements/GenericExt.js +0 -26
  238. package/dist/test-resources/elements/NoShadowDOM.js +0 -13
  239. package/dist/test-resources/elements/Parent.js +0 -37
  240. package/dist/test-resources/elements/WithStaticArea.js +0 -76
  241. package/dist/test-resources/pages/AllTestElements.html +0 -42
  242. package/dist/test-resources/pages/Configuration.html +0 -20
  243. package/dist/test-resources/pages/ConfigurationScript.html +0 -36
  244. package/dist/test-resources/pages/assets/messagebundle_de.properties +0 -1
  245. package/dist/test-resources/pages/assets/messagebundle_en.properties +0 -1
  246. package/dist/test-resources/pages/assets/messagebundle_es.properties +0 -1
  247. package/dist/test-resources/pages/assets/messagebundle_fr.properties +0 -1
  248. package/dist/test-resources/pages/i18n.html +0 -40
  249. package/dist/test-resources/specs/ConfigurationChange.spec.js +0 -25
  250. package/dist/test-resources/specs/ConfigurationScript.spec.js +0 -61
  251. package/dist/test-resources/specs/ConfigurationURL.spec.js +0 -45
  252. package/dist/test-resources/specs/CustomTheme.spec.js +0 -25
  253. package/dist/test-resources/specs/StaticArea.spec.js +0 -34
  254. package/dist/test-resources/specs/Theming.spec.js +0 -31
  255. package/dist/test-resources/specs/UI5ElementInvalidation.js +0 -258
  256. package/dist/test-resources/specs/UI5ElementLifecycle.js +0 -96
  257. package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +0 -101
  258. package/dist/test-resources/specs/UI5ElementMetadataExt.js +0 -40
  259. package/dist/test-resources/specs/UI5ElementPropertyValidation.js +0 -12
  260. package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +0 -65
  261. package/dist/test-resources/specs/UI5ElementShadowDOM.js +0 -22
  262. package/dist/test-resources/specs/UI5ElementSlots.js +0 -34
  263. package/dist/theming/CSSVarsPonyfill.js +0 -68
  264. package/dist/theming/adaptCSSForIE.js +0 -95
  265. package/dist/theming/createComponentStyleTag.js +0 -54
  266. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  267. package/dist/thirdparty/Array.from.js +0 -16
  268. package/dist/thirdparty/Array.prototype.fill.js +0 -44
  269. package/dist/thirdparty/Array.prototype.find.js +0 -46
  270. package/dist/thirdparty/Array.prototype.includes.js +0 -51
  271. package/dist/thirdparty/Element.prototype.closest.js +0 -11
  272. package/dist/thirdparty/Element.prototype.matches.js +0 -6
  273. package/dist/thirdparty/Map.prototype.keys.js +0 -9
  274. package/dist/thirdparty/Number.isInteger.js +0 -5
  275. package/dist/thirdparty/Number.isNaN.js +0 -1
  276. package/dist/thirdparty/Number.parseFloat.js +0 -1
  277. package/dist/thirdparty/Number.parseInt.js +0 -1
  278. package/dist/thirdparty/Object.assign.js +0 -31
  279. package/dist/thirdparty/Object.entries.js +0 -11
  280. package/dist/thirdparty/Symbol.js +0 -2
  281. package/dist/thirdparty/WeakSet.js +0 -27
  282. package/dist/thirdparty/es6-string-methods.js +0 -182
  283. package/dist/thirdparty/events-polyfills.js +0 -89
  284. package/dist/thirdparty/fetch.js +0 -1
  285. package/dist/thirdparty/template.js +0 -600
  286. package/dist/thirdparty/webcomponents-sd-ce-pf.js +0 -318
  287. package/dist/util/EffectiveAssetPath.js +0 -27
  288. package/dist/util/encodeCSS.js +0 -24
  289. package/dist/util/findNodeOwner.js +0 -35
  290. package/dist/util/isSlot.js +0 -3
  291. package/dist/webcomponentsjs/LICENSE.md +0 -19
  292. package/dist/webcomponentsjs/README.md +0 -229
  293. package/dist/webcomponentsjs/bundles/webcomponents-ce.js +0 -63
  294. package/dist/webcomponentsjs/bundles/webcomponents-ce.js.map +0 -1
  295. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js +0 -297
  296. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js.map +0 -1
  297. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce.js +0 -208
  298. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce.js.map +0 -1
  299. package/dist/webcomponentsjs/bundles/webcomponents-sd.js +0 -166
  300. package/dist/webcomponentsjs/bundles/webcomponents-sd.js.map +0 -1
  301. package/dist/webcomponentsjs/custom-elements-es5-adapter.js +0 -15
  302. package/dist/webcomponentsjs/package.json +0 -46
  303. package/dist/webcomponentsjs/src/entrypoints/custom-elements-es5-adapter-index.js +0 -16
  304. package/dist/webcomponentsjs/src/entrypoints/webcomponents-bundle-index.js +0 -53
  305. package/dist/webcomponentsjs/src/entrypoints/webcomponents-ce-index.js +0 -17
  306. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-index.js +0 -19
  307. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-pf-index.js +0 -28
  308. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-index.js +0 -18
  309. package/dist/webcomponentsjs/webcomponents-bundle.js +0 -298
  310. package/dist/webcomponentsjs/webcomponents-bundle.js.map +0 -1
  311. package/dist/webcomponentsjs/webcomponents-loader.js +0 -185
  312. package/src/SVGIconRegistry.js +0 -73
  313. package/src/boot.js +0 -34
  314. package/src/compatibility/DOMObserver.js +0 -62
  315. package/src/compatibility/patchNodeValue.js +0 -24
  316. package/src/compatibility/whenPolyfillLoaded.js +0 -26
  317. package/src/config/AssetsPath.js +0 -17
  318. package/src/delegate/CustomResize.js +0 -78
  319. package/src/delegate/NativeResize.js +0 -45
  320. package/src/features/PropertiesFormatSupport.js +0 -8
  321. package/src/features/browsersupport/Edge.js +0 -6
  322. package/src/features/browsersupport/IE11.js +0 -42
  323. package/src/features/browsersupport/IE11WithWebComponentsPolyfill.js +0 -5
  324. package/src/renderer/ifDefined.js +0 -21
  325. package/src/renderer/scopeHTML.js +0 -32
  326. package/src/theming/CSSVarsPonyfill.js +0 -68
  327. package/src/theming/adaptCSSForIE.js +0 -95
  328. package/src/theming/createComponentStyleTag.js +0 -54
  329. package/src/theming/createThemePropertiesStyleTag.js +0 -20
  330. package/src/thirdparty/Array.from.js +0 -16
  331. package/src/thirdparty/Array.prototype.fill.js +0 -44
  332. package/src/thirdparty/Array.prototype.find.js +0 -46
  333. package/src/thirdparty/Array.prototype.includes.js +0 -51
  334. package/src/thirdparty/Element.prototype.closest.js +0 -11
  335. package/src/thirdparty/Element.prototype.matches.js +0 -6
  336. package/src/thirdparty/Map.prototype.keys.js +0 -9
  337. package/src/thirdparty/Number.isInteger.js +0 -5
  338. package/src/thirdparty/Number.isNaN.js +0 -1
  339. package/src/thirdparty/Number.parseFloat.js +0 -1
  340. package/src/thirdparty/Number.parseInt.js +0 -1
  341. package/src/thirdparty/Object.assign.js +0 -31
  342. package/src/thirdparty/Object.entries.js +0 -11
  343. package/src/thirdparty/Symbol.js +0 -2
  344. package/src/thirdparty/WeakSet.js +0 -27
  345. package/src/thirdparty/es6-string-methods.js +0 -182
  346. package/src/thirdparty/events-polyfills.js +0 -89
  347. package/src/thirdparty/fetch.js +0 -1
  348. package/src/thirdparty/template.js +0 -600
  349. package/src/thirdparty/webcomponents-sd-ce-pf.js +0 -318
  350. package/src/util/EffectiveAssetPath.js +0 -27
  351. package/src/util/encodeCSS.js +0 -24
  352. package/src/util/findNodeOwner.js +0 -35
  353. package/src/util/isSlot.js +0 -3
package/src/Device.js CHANGED
@@ -1,823 +1,121 @@
1
- /**
2
- * Device and Feature Detection API: Provides information about the used browser / device and cross platform support for certain events
3
- * like media queries, orientation change or resizing.
4
- *
5
- * This API is independent from any other part of the UI5 framework. This allows it to be loaded beforehand, if it is needed, to create the UI5 bootstrap
6
- * dynamically depending on the capabilities of the browser or device.
7
- *
8
- * @namespace
9
- * @name Device
10
- */
1
+ const ua = navigator.userAgent;
2
+ const touch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
3
+ const ie = /(msie|trident)/i.test(ua);
4
+ const chrome = !ie && /(Chrome|CriOS)/.test(ua);
5
+ const safari = !ie && !chrome && /(Version|PhantomJS)\/(\d+\.\d+).*Safari/.test(ua);
6
+ const webkit = !ie && /webkit/.test(ua);
7
+ const windows = navigator.platform.indexOf("Win") !== -1;
8
+ const iOS = navigator.platform.match(/iPhone|iPad|iPod/) || (navigator.userAgent.match(/Mac/) && "ontouchend" in document);
9
+ const android = !windows && /Android/.test(ua);
10
+ const androidPhone = android && /(?=android)(?=.*mobile)/i.test(ua);
11
+ const ipad = /ipad/i.test(ua) || (/Macintosh/i.test(ua) && "ontouchend" in document);
12
+ // With iOS 13 the string 'iPad' was removed from the user agent string through a browser setting, which is applied on all sites by default:
13
+ // "Request Desktop Website -> All websites" (for more infos see: https://forums.developer.apple.com/thread/119186).
14
+ // Therefore the OS is detected as MACINTOSH instead of iOS and the device is a tablet if the Device.support.touch is true.
11
15
 
12
- const Device = {};
16
+ let windowsVersion;
17
+ let webkitVersion;
18
+ let tablet;
13
19
 
14
- //* ******* OS Detection ********
15
-
16
- /**
17
- * Contains information about the operating system of the Device.
18
- * @name Device.os
19
- */
20
-
21
- /**
22
- * Enumeration containing the names of known operating systems.
23
- * @name Device.os.OS
24
- */
25
-
26
- /**
27
- * The name of the operating system.
28
- * @name Device.os.name
29
- * @type String
30
- */
31
-
32
- /**
33
- * The version of the operating system as <code>string</code>. Might be empty if no version can be determined.
34
- * @name Device.os.versionStr
35
- * @type String
36
- */
37
-
38
- /**
39
- * The version of the operating system as <code>float</code>. Might be <code>-1</code> if no version can be determined.
40
- * @name Device.os.version
41
- * @type float
42
- */
43
-
44
- /**
45
- * If this flag is set to <code>true</code>, a Windows operating system is used.
46
- * @name Device.os.windows
47
- * @type boolean
48
- */
49
-
50
- /**
51
- * If this flag is set to <code>true</code>, a Mac operating system is used.
52
- * @name Device.os.macintosh
53
- * @type boolean
54
- */
55
-
56
- /*
57
- * If this flag is set to <code>true</code>, an iOS operating system is used.
58
- * @name Device.os.ios
59
- * @type boolean
60
- */
61
-
62
- /**
63
- * If this flag is set to <code>true</code>, an Android operating system is used.
64
- * @name Device.os.android
65
- * @type boolean
66
- */
67
-
68
- /*
69
- * Windows operating system name.
70
- * @see Device.os.name
71
- * @name Device.os.OS.WINDOWS
72
- */
73
-
74
- /**
75
- * MAC operating system name.
76
- * @see Device.os.name
77
- * @name Device.os.OS.MACINTOSH
78
- */
79
-
80
- /**
81
- * iOS operating system name.
82
- * @see Device.os.name
83
- * @name Device.os.OS.IOS
84
- */
85
-
86
- /**
87
- * Android operating system name.
88
- * @see Device.os.name
89
- * @name Device.os.OS.ANDROID
90
- */
91
-
92
- const OS = {
93
- "WINDOWS": "win",
94
- "MACINTOSH": "mac",
95
- "IOS": "iOS",
96
- "ANDROID": "Android",
97
- };
98
-
99
- const _getMobileOS = () => {
100
- const userAgent = navigator.userAgent;
101
-
102
- let rPlatform, // regular expression for platform
103
- aMatches;
104
-
105
- // iOS, Android
106
- rPlatform = /\(([a-zA-Z ]+);\s(?:[U]?[;]?)([\D]+)((?:[\d._]*))(?:.*[)][^\d]*)([\d.]*)\s/;
107
- aMatches = userAgent.match(rPlatform);
108
-
109
- if (aMatches) {
110
- const rAppleDevices = /iPhone|iPad|iPod/;
111
-
112
- if (aMatches[0].match(rAppleDevices)) {
113
- aMatches[3] = aMatches[3].replace(/_/g, ".");
114
-
115
- return ({
116
- "name": OS.IOS,
117
- "versionStr": aMatches[3],
118
- });
119
- }
120
-
121
- if (aMatches[2].match(/Android/)) {
122
- aMatches[2] = aMatches[2].replace(/\s/g, "");
123
- return ({
124
- "name": OS.ANDROID,
125
- "versionStr": aMatches[3],
126
- });
127
- }
128
- }
129
-
130
- // Firefox on Android
131
- rPlatform = /\((Android)[\s]?([\d][.\d]*)?;.*Firefox\/[\d][.\d]*/;
132
- aMatches = userAgent.match(rPlatform);
133
- if (aMatches) {
134
- return ({
135
- "name": OS.ANDROID,
136
- "versionStr": aMatches.length === 3 ? aMatches[2] : "",
137
- });
138
- }
139
- };
140
-
141
- const _getDesktopOS = () => {
142
- const sPlatform = navigator.platform;
143
- if (sPlatform.indexOf("Win") !== -1) {
144
- const rVersion = /Windows NT (\d+).(\d)/i; // userAgent since windows 10: Windows NT 10[...]
145
- const uaResult = navigator.userAgent.match(rVersion);
146
-
147
- return {
148
- "name": OS.WINDOWS,
149
- "versionStr": (uaResult && uaResult[1]) || "",
150
- };
20
+ const isWindows8OrAbove = () => {
21
+ if (!windows) {
22
+ return false;
151
23
  }
152
24
 
153
- if (sPlatform.indexOf("Mac") !== -1) {
154
- return {
155
- "name": OS.MACINTOSH,
156
- "versionStr": "",
157
- };
25
+ if (windowsVersion === undefined) {
26
+ const matches = ua.match(/Windows NT (\d+).(\d)/);
27
+ windowsVersion = matches ? parseFloat(matches[1]) : 0;
158
28
  }
159
29
 
160
- return null;
161
- };
162
-
163
- const _getOS = () => {
164
- return _getMobileOS() || _getDesktopOS();
165
- };
166
-
167
- const _setOS = () => {
168
- if (Device.os) {
169
- return;
170
- }
171
-
172
- Device.os = _getOS() || {};
173
- Device.os.OS = OS;
174
- Device.os.version = Device.os.versionStr ? parseFloat(Device.os.versionStr) : -1;
175
-
176
- if (Device.os.name) {
177
- Object.keys(OS).forEach(name => {
178
- if (OS[name] === Device.os.name) {
179
- Device.os[name.toLowerCase()] = true;
180
- }
181
- });
182
- }
30
+ return windowsVersion >= 8;
183
31
  };
184
32
 
185
- const getOS = () => {
186
- if (!Device.os) {
187
- _setOS();
33
+ const isWebkit537OrAbove = () => {
34
+ if (!webkit) {
35
+ return false;
188
36
  }
189
37
 
190
- return Device.os;
191
- };
192
-
193
- const isAndroid = () => {
194
- if (!Device.os) {
195
- _setOS();
38
+ if (webkitVersion === undefined) {
39
+ const matches = ua.match(/(webkit)[ /]([\w.]+)/);
40
+ webkitVersion = matches ? parseFloat(matches[1]) : 0;
196
41
  }
197
42
 
198
- return !!Device.os.android;
43
+ return webkitVersion >= 537.10;
199
44
  };
200
45
 
201
- //* ******* Browser Detection ********
202
-
203
- /**
204
- * Contains information about the used browser.
205
- * @name Device.browser
206
- */
207
-
208
- /**
209
- * Enumeration containing the names of known browsers.
210
- * @name Device.browser.BROWSER
211
- *
212
- * The name of the browser.
213
- * @name Device.browser.name
214
- * @type String
215
- */
216
-
217
- /**
218
- * The version of the browser as <code>string</code>. Might be empty if no version can be determined.
219
- * @name Device.browser.versionStr
220
- * @type String
221
- */
222
-
223
- /**
224
- * The version of the browser as <code>float</code>. Might be <code>-1</code> if no version can be determined.
225
- * @name Device.browser.version
226
- * @type float
227
- */
228
-
229
- /**
230
- * If this flag is set to <code>true</code>, the mobile variant of the browser is used or
231
- * a tablet or phone device is detected. This information might not be available for all browsers.
232
- * @name Device.browser.mobile
233
- * @type boolean
234
- */
235
-
236
- /**
237
- * If this flag is set to <code>true</code>, the Microsoft Internet Explorer browser is used.
238
- * @name Device.browser.internet_explorer
239
- * @type boolean
240
- * @deprecated since 1.20, use {@link Device.browser.msie} instead.
241
- */
242
-
243
- /**
244
- * If this flag is set to <code>true</code>, the Microsoft Internet Explorer browser is used.
245
- * @name Device.browser.msie
246
- * @type boolean
247
- */
248
-
249
- /**
250
- * If this flag is set to <code>true</code>, the Microsoft Edge browser is used.
251
- * @name Device.browser.edge
252
- * @type boolean
253
- */
254
-
255
- /**
256
- * If this flag is set to <code>true</code>, the Mozilla Firefox browser is used.
257
- * @name Device.browser.firefox
258
- */
259
-
260
- /**
261
- * If this flag is set to <code>true</code>, the Google Chrome browser is used.
262
- * @name Device.browser.chrome
263
- * @type boolean
264
- *
265
- * If this flag is set to <code>true</code>, the Apple Safari browser is used.
266
- *
267
- * <b>Note:</b>
268
- * This flag is also <code>true</code> when the standalone (fullscreen) mode or webview is used on iOS devices.
269
- * Please also note the flags {@link Device.browser.fullscreen} and {@link Device.browser.webview}.
270
- *
271
- * @name Device.browser.safari
272
- * @type boolean
273
- */
274
-
275
- /**
276
- * If this flag is set to <code>true</code>, a browser featuring a Webkit engine is used.
277
- *
278
- * <b>Note:</b>
279
- * This flag is also <code>true</code> when the used browser was based on the Webkit engine, but
280
- * uses another rendering engine in the meantime. For example the Chrome browser started from version 28 and above
281
- * uses the Blink rendering engine.
282
- *
283
- * @name Device.browser.webkit
284
- * @type boolean
285
- */
286
-
287
- /**
288
- * If this flag is set to <code>true</code>, the Safari browser runs in standalone fullscreen mode on iOS.
289
- *
290
- * <b>Note:</b> This flag is only available if the Safari browser was detected. Furthermore, if this mode is detected,
291
- * technically not a standard Safari is used. There might be slight differences in behavior and detection, e.g.
292
- * the availability of {@link Device.browser.version}.
293
- *
294
- * @name Device.browser.fullscreen
295
- * @type boolean
296
- */
297
-
298
- /**
299
- * If this flag is set to <code>true</code>, the Safari browser runs in webview mode on iOS.
300
- *
301
- * <b>Note:</b> This flag is only available if the Safari browser was detected. Furthermore, if this mode is detected,
302
- * technically not a standard Safari is used. There might be slight differences in behavior and detection, e.g.
303
- * the availability of {@link Device.browser.version}.
304
- *
305
- * @name Device.browser.webview
306
- * @type boolean
307
- */
308
-
309
- /**
310
- * If this flag is set to <code>true</code>, the Phantom JS browser is used.
311
- * @name Device.browser.phantomJS
312
- * @type boolean
313
- */
314
-
315
- /**
316
- * The version of the used Webkit engine, if available.
317
- * @name Device.browser.webkitVersion
318
- * @type String
319
- */
320
-
321
- /**
322
- * If this flag is set to <code>true</code>, a browser featuring a Mozilla engine is used.
323
- * @name Device.browser.mozilla
324
- * @type boolean
325
- */
326
-
327
- /**
328
- * Internet Explorer browser name.
329
- * @name Device.browser.BROWSER.INTERNET_EXPLORER
330
- */
331
-
332
- /**
333
- * Edge browser name.
334
- * @name Device.browser.BROWSER.EDGE
335
- */
336
-
337
- /**
338
- * Firefox browser name.
339
- * @name Device.browser.BROWSER.FIREFOX
340
- */
341
-
342
- /**
343
- * Chrome browser name.
344
- * @name Device.browser.BROWSER.CHROME
345
- */
346
-
347
- /**
348
- * Safari browser name.
349
- * @name Device.browser.BROWSER.SAFARI
350
- */
351
-
352
- /**
353
- * Android stock browser name.
354
- * @name Device.browser.BROWSER.ANDROID
355
- */
356
-
357
- const BROWSER = {
358
- "INTERNET_EXPLORER": "ie",
359
- "EDGE": "ed",
360
- "FIREFOX": "ff",
361
- "CHROME": "cr",
362
- "SAFARI": "sf",
363
- "ANDROID": "an",
364
- };
365
-
366
- /*!
367
- * Taken from jQuery JavaScript Library v1.7.1
368
- * http://jquery.com/
369
- *
370
- * Copyright 2011, John Resig
371
- * Dual licensed under the MIT or GPL Version 2 licenses.
372
- * http://jquery.org/license
373
- *
374
- * Includes Sizzle.js
375
- * http://sizzlejs.com/
376
- * Copyright 2011, The Dojo Foundation
377
- * Released under the MIT, BSD, and GPL Licenses.
378
- *
379
- * Date: Mon Nov 21 21:11:03 2011 -0500
380
- */
381
- const _calcBrowser = () => {
382
- const sUserAgent = navigator.userAgent.toLowerCase();
383
-
384
- const rwebkit = /(webkit)[ /]([\w.]+)/;
385
- const rmsie = /(msie) ([\w.]+)/;
386
- const rmsie11 = /(trident)\/[\w.]+;.*rv:([\w.]+)/;
387
- const redge = /(edge)[ /]([\w.]+)/;
388
- const rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;
389
-
390
- // WinPhone IE11 and MS Edge userAgents contain "WebKit" and "Mozilla" and therefore must be checked first
391
- const browserMatch = redge.exec(sUserAgent)
392
- || rmsie11.exec(sUserAgent)
393
- || rwebkit.exec(sUserAgent)
394
- || rmsie.exec(sUserAgent)
395
- || (sUserAgent.indexOf("compatible") < 0 && rmozilla.exec(sUserAgent)) || [];
396
-
397
- const oRes = {
398
- browser: browserMatch[1] || "",
399
- version: browserMatch[2] || "0",
400
- };
401
- oRes[oRes.browser] = true;
402
- return oRes;
403
- };
404
-
405
- const _getBrowser = () => {
406
- const oBrowser = _calcBrowser();
407
- const sUserAgent = navigator.userAgent;
408
- const oNavigator = window.navigator;
409
-
410
- // jQuery checks for user agent strings. We differentiate between browsers
411
- let oExpMobile;
412
- let oResult;
413
- let fVersion;
414
-
415
- // Mozilla
416
- if (oBrowser.mozilla) {
417
- oExpMobile = /Mobile/;
418
- if (sUserAgent.match(/Firefox\/(\d+\.\d+)/)) {
419
- fVersion = parseFloat(RegExp.$1);
420
- oResult = {
421
- name: BROWSER.FIREFOX,
422
- versionStr: `${fVersion}`,
423
- version: fVersion,
424
- mozilla: true,
425
- mobile: oExpMobile.test(sUserAgent),
426
- };
427
- } else {
428
- // unknown mozilla browser
429
- oResult = {
430
- mobile: oExpMobile.test(sUserAgent),
431
- mozilla: true,
432
- version: -1,
433
- };
434
- }
435
- } else if (oBrowser.webkit) {
436
- // webkit version is needed for calculation if the mobile android device is a tablet (calculation of other mobile devices work without)
437
- const regExpWebkitVersion = sUserAgent.toLowerCase().match(/webkit[/]([\d.]+)/);
438
- let webkitVersion;
439
- if (regExpWebkitVersion) {
440
- webkitVersion = regExpWebkitVersion[1];
441
- }
442
- oExpMobile = /Mobile/;
443
- const aChromeMatch = sUserAgent.match(/(Chrome|CriOS)\/(\d+\.\d+).\d+/);
444
- const aFirefoxMatch = sUserAgent.match(/FxiOS\/(\d+\.\d+)/);
445
- const aAndroidMatch = sUserAgent.match(/Android .+ Version\/(\d+\.\d+)/);
446
-
447
- if (aChromeMatch || aFirefoxMatch || aAndroidMatch) {
448
- let sName,
449
- sVersion,
450
- bMobile;
451
-
452
- if (aChromeMatch) {
453
- sName = BROWSER.CHROME;
454
- bMobile = oExpMobile.test(sUserAgent);
455
- sVersion = parseFloat(aChromeMatch[2]);
456
- } else if (aFirefoxMatch) {
457
- sName = BROWSER.FIREFOX;
458
- bMobile = true;
459
- sVersion = parseFloat(aFirefoxMatch[1]);
460
- } else if (aAndroidMatch) {
461
- sName = BROWSER.ANDROID;
462
- bMobile = oExpMobile.test(sUserAgent);
463
- sVersion = parseFloat(aAndroidMatch[1]);
464
- }
465
-
466
- oResult = {
467
- name: sName,
468
- mobile: bMobile,
469
- versionStr: `${sVersion}`,
470
- version: sVersion,
471
- webkit: true,
472
- webkitVersion,
473
- };
474
- } else { // Safari might have an issue with sUserAgent.match(...); thus changing
475
- const oExp = /(Version|PhantomJS)\/(\d+\.\d+).*Safari/;
476
- const bStandalone = oNavigator.standalone;
477
- if (oExp.test(sUserAgent)) {
478
- const aParts = oExp.exec(sUserAgent);
479
- fVersion = parseFloat(aParts[2]);
480
- oResult = {
481
- name: BROWSER.SAFARI,
482
- versionStr: `${fVersion}`,
483
- fullscreen: false,
484
- webview: false,
485
- version: fVersion,
486
- mobile: oExpMobile.test(sUserAgent),
487
- webkit: true,
488
- webkitVersion,
489
- phantomJS: aParts[1] === "PhantomJS",
490
- };
491
- } else if (/iPhone|iPad|iPod/.test(sUserAgent) && !(/CriOS/.test(sUserAgent)) && !(/FxiOS/.test(sUserAgent)) && (bStandalone === true || bStandalone === false)) {
492
- // WebView or Standalone mode on iOS
493
- oResult = {
494
- name: BROWSER.SAFARI,
495
- version: -1,
496
- fullscreen: bStandalone,
497
- webview: !bStandalone,
498
- mobile: oExpMobile.test(sUserAgent),
499
- webkit: true,
500
- webkitVersion,
501
- };
502
- } else { // other webkit based browser
503
- oResult = {
504
- mobile: oExpMobile.test(sUserAgent),
505
- webkit: true,
506
- webkitVersion,
507
- version: -1,
508
- };
509
- }
510
- }
511
- } else if (oBrowser.msie || oBrowser.trident) {
512
- fVersion = parseFloat(oBrowser.version);
513
-
514
- oResult = {
515
- name: BROWSER.INTERNET_EXPLORER,
516
- versionStr: `${fVersion}`,
517
- version: fVersion,
518
- msie: true,
519
- mobile: false,
520
- };
521
- } else if (oBrowser.edge) {
522
- fVersion = parseFloat(oBrowser.version);
523
- oResult = {
524
- name: BROWSER.EDGE,
525
- versionStr: `${fVersion}`,
526
- version: fVersion,
527
- edge: true,
528
- };
529
- } else {
530
- oResult = {
531
- name: "",
532
- versionStr: "",
533
- version: -1,
534
- mobile: false,
535
- };
536
- }
537
-
538
- return oResult;
539
- };
540
-
541
- const _setBrowser = () => {
542
- Device.browser = _getBrowser();
543
- Device.browser.BROWSER = BROWSER;
544
-
545
- if (Device.browser.name) {
546
- Object.keys(BROWSER).forEach(b => {
547
- if (BROWSER[b] === Device.browser.name) {
548
- Device.browser[b.toLowerCase()] = true;
549
- }
550
- });
551
- }
552
- };
553
-
554
- const getBrowser = () => {
555
- if (!Device.browser) {
556
- _setBrowser();
557
- }
558
- return Device.browser;
559
- };
560
-
561
- const isIE = () => {
562
- if (!Device.browser) {
563
- _setBrowser();
564
- }
565
- return !!Device.browser.msie;
566
- };
567
-
568
- const isEdge = () => {
569
- if (!Device.browser) {
570
- _setBrowser();
571
- }
572
- return !!Device.browser.edge;
573
- };
574
-
575
- const isChrome = () => {
576
- if (!Device.browser) {
577
- _setBrowser();
578
- }
579
- return !!Device.browser.chrome;
580
- };
581
-
582
- const isFF = () => {
583
- if (!Device.browser) {
584
- _setBrowser();
585
- }
586
- return !!Device.browser.firefox;
587
- };
588
-
589
- const isSafari = () => {
590
- if (!Device.browser) {
591
- _setBrowser();
592
- }
593
- return !!Device.browser.safari;
594
- };
595
-
596
- //* ******* Support Detection ********
597
-
598
- const _setSupport = () => {
599
- if (Device.support) {
46
+ const detectTablet = () => {
47
+ if (tablet !== undefined) {
600
48
  return;
601
49
  }
602
50
 
603
- if (!Device.browser) {
604
- _setBrowser();
605
- }
606
-
607
- Device.support = {};
608
- Device.support.touch = !!(("ontouchstart" in window) || (navigator.maxTouchPoints > 0) || (window.DocumentTouch && document instanceof window.DocumentTouch));
609
- };
610
-
611
- const supportTouch = () => {
612
- if (!Device.support) {
613
- _setSupport();
51
+ if (ipad) {
52
+ tablet = true;
53
+ return;
614
54
  }
615
55
 
616
- return !!Device.support.touch;
617
- };
618
-
619
- //* ******* System Detection ********
620
-
621
- /**
622
- * Provides a basic categorization of the used device based on various indicators.
623
- *
624
- * <b>Note:</b> Depending on the capabilities of the device it is also possible that multiple flags are set to <code>true</code>.
625
- *
626
- * @namespace
627
- * @name Device.system
628
- */
629
-
630
- /**
631
- * If this flag is set to <code>true</code>, the device is recognized as a tablet.
632
- *
633
- * <b>Note:</b> This flag is also true for some browsers on desktop devices running on Windows 8 or higher.
634
- * Also see the documentation for {@link Device.system.combi} devices.
635
- * You can use the following logic to ensure that the current device is a tablet device:
636
- *
637
- * <pre>
638
- * if(Device.system.tablet && !Device.system.desktop){
639
- * ...tablet related commands...
640
- * }
641
- * </pre>
642
- *
643
- * @name Device.system.tablet
644
- * @type boolean
645
- */
646
-
647
- /**
648
- * If this flag is set to <code>true</code>, the device is recognized as a phone.
649
- *
650
- * @name Device.system.phone
651
- * @type boolean
652
- */
653
-
654
- /**
655
- * If this flag is set to <code>true</code>, the device is recognized as a desktop system.
656
- *
657
- * @name Device.system.desktop
658
- * @type boolean
659
- */
660
-
661
- /**
662
- * Indicates if the device is recognized as a combination of a desktop system and tablet.
663
- *
664
- * <b>Note:</b> This property is mainly for Microsoft Windows 8 (and following) devices where the mouse and touch event may be supported
665
- * natively by the browser being used. This property is set to <code>true</code> only when both mouse and touch event are natively supported.
666
- *
667
- * @name Device.system.combi
668
- * @type boolean
669
- */
670
-
671
- /**
672
- * @name Device.system.SYSTEMTYPE
673
- * Enumeration containing the names of known types of the devices.
674
- */
675
-
676
- const SYSTEMTYPE = {
677
- "TABLET": "tablet",
678
- "PHONE": "phone",
679
- "DESKTOP": "desktop",
680
- "COMBI": "combi",
681
- };
682
-
683
- const _isTablet = () => {
684
- const sUserAgent = navigator.userAgent;
685
- if (Device.os.name === Device.os.OS.IOS) {
686
- return /ipad/i.test(sUserAgent);
687
- }
688
- // in real mobile device
689
- if (supportTouch()) {
690
- if (Device.os.windows && Device.os.version >= 8) {
691
- return true;
56
+ if (touch) {
57
+ if (isWindows8OrAbove()) {
58
+ tablet = true;
59
+ return;
692
60
  }
693
61
 
694
- if (Device.browser.chrome && Device.os.android && Device.os.version >= 4.4) {
695
- // From Android version 4.4, WebView also uses Chrome as Kernel.
696
- // We can use the user agent pattern defined in Chrome to do phone/tablet detection
697
- // According to the information here: https://developer.chrome.com/multidevice/user-agent#chrome_for_android_user_agent,
698
- // the existence of "Mobile" indicates it's a phone. But because the crosswalk framework which is used in Fiori Client
699
- // inserts another "Mobile" to the user agent for both tablet and phone, we need to check whether "Mobile Safari/<Webkit Rev>" exists.
700
- return !/Mobile Safari\/[.0-9]+/.test(sUserAgent);
62
+ if (chrome && android) {
63
+ tablet = !/Mobile Safari\/[.0-9]+/.test(ua);
64
+ return;
701
65
  }
66
+
702
67
  let densityFactor = window.devicePixelRatio ? window.devicePixelRatio : 1; // may be undefined in Windows Phone devices
703
- // On Android sometimes window.screen.width returns the logical CSS pixels, sometimes the physical device pixels;
704
- // Tests on multiple devices suggest this depends on the Webkit version.
705
- // The Webkit patch which changed the behavior was done here: https://bugs.webkit.org/show_bug.cgi?id=106460
706
- // Chrome 27 with Webkit 537.36 returns the logical pixels,
707
- // Chrome 18 with Webkit 535.19 returns the physical pixels.
708
- // The BlackBerry 10 browser with Webkit 537.10+ returns the physical pixels.
709
- // So it appears like somewhere above Webkit 537.10 we do not hve to divide by the devicePixelRatio anymore.
710
- if (Device.os.android && Device.browser.webkit && (parseFloat(Device.browser.webkitVersion) > 537.10)) {
68
+ if (android && isWebkit537OrAbove()) {
711
69
  densityFactor = 1;
712
70
  }
713
71
 
714
- // this is how android distinguishes between tablet and phone
715
- // http://android-developers.blogspot.de/2011/07/new-tools-for-managing-screen-sizes.html
716
- const bTablet = (Math.min(window.screen.width / densityFactor, window.screen.height / densityFactor) >= 600);
717
-
718
- // special workaround for Nexus 7 where the window.screen.width is 600px or 601px in portrait mode (=> tablet)
719
- // but window.screen.height 552px in landscape mode (=> phone), because the browser UI takes some space on top.
720
- // So the detected device type depends on the orientation :-(
721
- // actually this is a Chrome bug, as "width"/"height" should return the entire screen's dimensions and
722
- // "availWidth"/"availHeight" should return the size available after subtracting the browser UI
723
-
724
- /*
725
- if (isLandscape() &&
726
- (window.screen.height === 552 || window.screen.height === 553) // old/new Nexus 7
727
- &&
728
- (/Nexus 7/i.test(sUserAgent))) {
729
- bTablet = true;
730
- }
731
- */
732
-
733
- return bTablet;
72
+ tablet = (Math.min(window.screen.width / densityFactor, window.screen.height / densityFactor) >= 600);
73
+ return;
734
74
  }
735
- // This simple android phone detection can be used here because this is the mobile emulation mode in desktop browser
736
- const bAndroidPhone = (/(?=android)(?=.*mobile)/i.test(sUserAgent));
737
- // in desktop browser, it's detected as tablet when
738
- // 1. Windows 8 device with a touch screen where "Touch" is contained in the userAgent
739
- // 2. Android emulation and it's not an Android phone
740
- return (Device.browser.msie && sUserAgent.indexOf("Touch") !== -1) || (Device.os.android && !bAndroidPhone);
741
- };
742
-
743
- const _getSystem = () => {
744
- const bTabletDetected = _isTablet();
745
- const isWin8Upwards = Device.os.windows && Device.os.version >= 8;
746
75
 
747
- const oSystem = {};
748
- oSystem.tablet = !!((Device.support.touch || isWin8Upwards) && bTabletDetected);
749
- oSystem.phone = !!((Device.os.windows_phone || (Device.support.touch)) && !bTabletDetected);
750
- oSystem.desktop = !!((!oSystem.tablet && !oSystem.phone) || isWin8Upwards);
751
- oSystem.combi = oSystem.desktop && oSystem.tablet;
752
- oSystem.SYSTEMTYPE = SYSTEMTYPE;
753
-
754
- return oSystem;
76
+ tablet = (ie && ua.indexOf("Touch") !== -1) || (android && !androidPhone);
755
77
  };
756
78
 
757
- const _setSystem = () => {
758
- _setSupport();
759
- _setOS();
79
+ const supportsTouch = () => touch;
80
+ const isIE = () => ie;
81
+ const isSafari = () => safari;
82
+ const isChrome = () => chrome;
760
83
 
761
- Device.system = {};
762
- Device.system = _getSystem();
763
- if (Device.system.tablet || Device.system.phone) {
764
- Device.browser.mobile = true;
765
- }
84
+ const isTablet = () => {
85
+ detectTablet();
86
+ return (touch || isWindows8OrAbove()) && tablet;
766
87
  };
767
88
 
768
- const getSystem = () => {
769
- if (!Device.system) {
770
- _setSystem();
771
- }
772
-
773
- return Device.system;
89
+ const isPhone = () => {
90
+ detectTablet();
91
+ return touch && !tablet;
774
92
  };
775
93
 
776
94
  const isDesktop = () => {
777
- if (!Device.system) {
778
- _setSystem();
779
- }
780
-
781
- return Device.system.desktop;
95
+ return (!isTablet() && !isPhone()) || isWindows8OrAbove();
782
96
  };
783
97
 
784
- const isTablet = () => {
785
- if (!Device.system) {
786
- _setSystem();
787
- }
788
-
789
- return Device.system.tablet;
98
+ const isCombi = () => {
99
+ return isTablet() && isDesktop();
790
100
  };
791
101
 
792
- const isPhone = () => {
793
- if (!Device.system) {
794
- _setSystem();
795
- }
796
-
797
- return Device.system.phone;
102
+ const isIOS = () => {
103
+ return iOS;
798
104
  };
799
105
 
800
- const isMobile = () => {
801
- if (!Device.system) {
802
- _setSystem();
803
- }
804
-
805
- return Device.browser.mobile;
106
+ const isAndroid = () => {
107
+ return android || androidPhone;
806
108
  };
807
109
 
808
110
  export {
111
+ supportsTouch,
809
112
  isIE,
810
- isEdge,
811
- isChrome,
812
- isFF,
813
113
  isSafari,
814
- isMobile,
815
- isDesktop,
816
- isTablet,
114
+ isChrome,
817
115
  isPhone,
116
+ isTablet,
117
+ isDesktop,
118
+ isCombi,
119
+ isIOS,
818
120
  isAndroid,
819
- getOS,
820
- getSystem,
821
- getBrowser,
822
- supportTouch,
823
121
  };