-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// A manual UMD build of Fscreen: https://github.com/rafrex/fscreen
(function(global) {
'use strict';
var key = {
fullscreenEnabled: 0,
fullscreenElement: 1,
requestFullscreen: 2,
exitFullscreen: 3,
fullscreenchange: 4,
fullscreenerror: 5
};
var webkit = ['webkitFullscreenEnabled', 'webkitFullscreenElement', 'webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitfullscreenchange', 'webkitfullscreenerror'];
var moz = ['mozFullScreenEnabled', 'mozFullScreenElement', 'mozRequestFullScreen', 'mozCancelFullScreen', 'mozfullscreenchange', 'mozfullscreenerror'];
var ms = ['msFullscreenEnabled', 'msFullscreenElement', 'msRequestFullscreen', 'msExitFullscreen', 'MSFullscreenChange', 'MSFullscreenError'];
// so it doesn't throw if no window or document
var doc = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
var vendor = 'fullscreenEnabled' in doc && Object.keys(key) || webkit[0] in doc && webkit || moz[0] in doc && moz || ms[0] in doc && ms || [];
var fscreen = {
requestFullscreen: function requestFullscreen(element) {
return element[vendor[key.requestFullscreen]]();
},
requestFullscreenFunction: function requestFullscreenFunction(element) {
return element[vendor[key.requestFullscreen]];
},
get exitFullscreen() {
return doc[vendor[key.exitFullscreen]].bind(doc);
},
addEventListener: function addEventListener(type, handler, options) {
return doc.addEventListener(vendor[key[type]], handler, options);
},
removeEventListener: function removeEventListener(type, handler) {
return doc.removeEventListener(vendor[key[type]], handler);
},
get fullscreenEnabled() {
return Boolean(doc[vendor[key.fullscreenEnabled]]);
},
set fullscreenEnabled(val) {},
get fullscreenElement() {
return doc[vendor[key.fullscreenElement]];
},
set fullscreenElement(val) {},
get onfullscreenchange() {
return doc[('on' + vendor[key.fullscreenchange]).toLowerCase()];
},
set onfullscreenchange(handler) {
return doc[('on' + vendor[key.fullscreenchange]).toLowerCase()] = handler;
},
get onfullscreenerror() {
return doc[('on' + vendor[key.fullscreenerror]).toLowerCase()];
},
set onfullscreenerror(handler) {
return doc[('on' + vendor[key.fullscreenerror]).toLowerCase()] = handler;
}
};
global.fscreen = fscreen;
})(window);