Skip to content

Adding Device checks (Mobile/Tablet) #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/checkDevice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#checkDevice
This is a small method to check whether the device user is using Mobile/Tablet.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please suggest better lines.
Thanks in advance



##Usage
```js
var Device = require('bv-ui-core/lib/checkDevice');
Device.isMobile();
Device.isTablet();
```
10 changes: 10 additions & 0 deletions lib/checkDevice/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
isMobile: function () {
return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
},
isTablet: function () {
var userAgent = navigator.userAgent.toLowerCase();
var isTablet = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(userAgent);
return isTablet;
}
}