Version 1
[yaffs-website] / node_modules / video.js / es5 / utils / browser.js
1 'use strict';
2
3 exports.__esModule = true;
4 exports.BACKGROUND_SIZE_SUPPORTED = exports.TOUCH_ENABLED = exports.IS_ANY_SAFARI = exports.IS_SAFARI = exports.IE_VERSION = exports.IS_IE8 = exports.IS_CHROME = exports.IS_EDGE = exports.IS_FIREFOX = exports.IS_NATIVE_ANDROID = exports.IS_OLD_ANDROID = exports.ANDROID_VERSION = exports.IS_ANDROID = exports.IOS_VERSION = exports.IS_IOS = exports.IS_IPOD = exports.IS_IPHONE = exports.IS_IPAD = undefined;
5
6 var _dom = require('./dom');
7
8 var Dom = _interopRequireWildcard(_dom);
9
10 var _window = require('global/window');
11
12 var _window2 = _interopRequireDefault(_window);
13
14 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
15
16 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
17
18 /**
19  * @file browser.js
20  * @module browser
21  */
22 var USER_AGENT = _window2['default'].navigator && _window2['default'].navigator.userAgent || '';
23 var webkitVersionMap = /AppleWebKit\/([\d.]+)/i.exec(USER_AGENT);
24 var appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null;
25
26 /*
27  * Device is an iPhone
28  *
29  * @type {Boolean}
30  * @constant
31  * @private
32  */
33 var IS_IPAD = exports.IS_IPAD = /iPad/i.test(USER_AGENT);
34
35 // The Facebook app's UIWebView identifies as both an iPhone and iPad, so
36 // to identify iPhones, we need to exclude iPads.
37 // http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/
38 var IS_IPHONE = exports.IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD;
39 var IS_IPOD = exports.IS_IPOD = /iPod/i.test(USER_AGENT);
40 var IS_IOS = exports.IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
41
42 var IOS_VERSION = exports.IOS_VERSION = function () {
43   var match = USER_AGENT.match(/OS (\d+)_/i);
44
45   if (match && match[1]) {
46     return match[1];
47   }
48   return null;
49 }();
50
51 var IS_ANDROID = exports.IS_ANDROID = /Android/i.test(USER_AGENT);
52 var ANDROID_VERSION = exports.ANDROID_VERSION = function () {
53   // This matches Android Major.Minor.Patch versions
54   // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
55   var match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
56
57   if (!match) {
58     return null;
59   }
60
61   var major = match[1] && parseFloat(match[1]);
62   var minor = match[2] && parseFloat(match[2]);
63
64   if (major && minor) {
65     return parseFloat(match[1] + '.' + match[2]);
66   } else if (major) {
67     return major;
68   }
69   return null;
70 }();
71
72 // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
73 var IS_OLD_ANDROID = exports.IS_OLD_ANDROID = IS_ANDROID && /webkit/i.test(USER_AGENT) && ANDROID_VERSION < 2.3;
74 var IS_NATIVE_ANDROID = exports.IS_NATIVE_ANDROID = IS_ANDROID && ANDROID_VERSION < 5 && appleWebkitVersion < 537;
75
76 var IS_FIREFOX = exports.IS_FIREFOX = /Firefox/i.test(USER_AGENT);
77 var IS_EDGE = exports.IS_EDGE = /Edge/i.test(USER_AGENT);
78 var IS_CHROME = exports.IS_CHROME = !IS_EDGE && /Chrome/i.test(USER_AGENT);
79 var IS_IE8 = exports.IS_IE8 = /MSIE\s8\.0/.test(USER_AGENT);
80 var IE_VERSION = exports.IE_VERSION = function () {
81   var result = /MSIE\s(\d+)\.\d/.exec(USER_AGENT);
82   var version = result && parseFloat(result[1]);
83
84   if (!version && /Trident\/7.0/i.test(USER_AGENT) && /rv:11.0/.test(USER_AGENT)) {
85     // IE 11 has a different user agent string than other IE versions
86     version = 11.0;
87   }
88
89   return version;
90 }();
91
92 var IS_SAFARI = exports.IS_SAFARI = /Safari/i.test(USER_AGENT) && !IS_CHROME && !IS_ANDROID && !IS_EDGE;
93 var IS_ANY_SAFARI = exports.IS_ANY_SAFARI = IS_SAFARI || IS_IOS;
94
95 var TOUCH_ENABLED = exports.TOUCH_ENABLED = Dom.isReal() && ('ontouchstart' in _window2['default'] || _window2['default'].DocumentTouch && _window2['default'].document instanceof _window2['default'].DocumentTouch);
96
97 var BACKGROUND_SIZE_SUPPORTED = exports.BACKGROUND_SIZE_SUPPORTED = Dom.isReal() && 'backgroundSize' in _window2['default'].document.createElement('video').style;