copay/js/services/isMobile.js

30 lines
805 B
JavaScript
Raw Normal View History

2014-06-19 11:07:20 -07:00
'use strict';
// Detect mobile devices
var isMobile = {
Android: function() {
return !!navigator.userAgent.match(/Android/i);
2014-06-19 11:07:20 -07:00
},
BlackBerry: function() {
return !!navigator.userAgent.match(/BlackBerry/i);
2014-06-19 11:07:20 -07:00
},
iOS: function() {
return !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
2014-06-19 11:07:20 -07:00
},
Opera: function() {
return !!navigator.userAgent.match(/Opera Mini/i);
2014-06-19 11:07:20 -07:00
},
Windows: function() {
return !!navigator.userAgent.match(/IEMobile/i);
2014-06-19 11:07:20 -07:00
},
2014-12-09 07:48:03 -08:00
Safari: function() {
return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
},
2014-06-19 11:07:20 -07:00
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
angular.module('copayApp.services').value('isMobile', isMobile);