Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
cfceaf49
Commit
cfceaf49
authored
Apr 21, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate user-agent to TS
parent
000f9cb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
user-agent.ts
src/shared/user-agent.ts
+6
-11
No files found.
src/shared/user-agent.
j
s
→
src/shared/user-agent.
t
s
View file @
cfceaf49
...
@@ -5,23 +5,20 @@
...
@@ -5,23 +5,20 @@
/**
/**
* Returns true when the OS is Mac OS.
* Returns true when the OS is Mac OS.
*
*
* @param _userAgent
{string}
- Test seam
* @param _userAgent - Test seam
*/
*/
export
const
isMacOS
=
(
_userAgent
=
window
.
navigator
.
userAgent
)
=>
{
export
const
isMacOS
=
(
_userAgent
:
string
=
window
.
navigator
.
userAgent
)
=>
{
return
_userAgent
.
indexOf
(
'Mac OS'
)
>=
0
;
return
_userAgent
.
indexOf
(
'Mac OS'
)
>=
0
;
};
};
/**
/**
* Returns true when device is iOS.
* Returns true when device is iOS.
* https://stackoverflow.com/a/9039885/14463679
* https://stackoverflow.com/a/9039885/14463679
*
* @param _navigator {{platform: string, userAgent: string}}
* @param _ontouchend {boolean}
*/
*/
export
const
isIOS
=
(
export
const
isIOS
=
(
_navigator
=
window
.
navigator
,
_navigator
:
{
platform
:
string
;
userAgent
:
string
}
=
window
.
navigator
,
_ontouchend
=
'ontouchend'
in
document
_ontouchend
:
boolean
=
'ontouchend'
in
document
)
=>
{
)
:
boolean
=>
{
return
(
return
(
[
[
'iPad Simulator'
,
'iPad Simulator'
,
...
@@ -40,9 +37,7 @@ export const isIOS = (
...
@@ -40,9 +37,7 @@ export const isIOS = (
* Returns true when the device is a touch device such
* Returns true when the device is a touch device such
* as android or iOS.
* as android or iOS.
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer#browser_compatibility
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer#browser_compatibility
*
* @param _window {Window} - Test seam
*/
*/
export
const
isTouchDevice
=
(
_window
=
window
)
=>
{
export
const
isTouchDevice
=
(
_window
:
Window
=
window
):
boolean
=>
{
return
_window
.
matchMedia
(
'(pointer: coarse)'
).
matches
;
return
_window
.
matchMedia
(
'(pointer: coarse)'
).
matches
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment