diff --git a/lib/checkDevice/README.md b/lib/checkDevice/README.md new file mode 100644 index 0000000..63c2033 --- /dev/null +++ b/lib/checkDevice/README.md @@ -0,0 +1,10 @@ +#checkDevice +This is a small method to check whether the device user is using Mobile/Tablet. + + +##Usage +```js +var Device = require('bv-ui-core/lib/checkDevice'); +Device.isMobile(); +Device.isTablet(); +``` diff --git a/lib/checkDevice/index.js b/lib/checkDevice/index.js new file mode 100644 index 0000000..a56ec68 --- /dev/null +++ b/lib/checkDevice/index.js @@ -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; + } +}