This repository was archived by the owner on Mar 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullscreen.js
More file actions
58 lines (58 loc) · 1.7 KB
/
fullscreen.js
File metadata and controls
58 lines (58 loc) · 1.7 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
/*!
* Fullscreen.js
* Fullscreen.js is a lightweight wrapper around the fullscreen API
* for fast and browser compliant development.
*
* @version 1.0.0
* @author Eliott Robson, https://eliottrobson.me
* @link https://github.com/eliottrobson/fullscreen.js
*/
var Fullscreen = (function () {
function Fullscreen(item) {
this.item = item;
}
Fullscreen.prototype.toggle = function (enable) {
if (typeof enable === "undefined") {
enable = !this.active();
}
if (enable) {
this.enable();
}
else {
this.disable();
}
};
Fullscreen.prototype.enable = function () {
var element = this.item;
if (element.requestFullscreen) {
element.requestFullscreen();
}
else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
}
else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
};
Fullscreen.prototype.disable = function () {
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
};
Fullscreen.prototype.active = function () {
return !!(document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement);
};
return Fullscreen;
}());