Skip to content
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;
}
}