securityos/node_modules/fscreen/dist/fscreen.esm.js

63 lines
2.6 KiB
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
var key = {
fullscreenEnabled: 0,
fullscreenElement: 1,
requestFullscreen: 2,
exitFullscreen: 3,
fullscreenchange: 4,
fullscreenerror: 5,
fullscreen: 6
};
var webkit = [
'webkitFullscreenEnabled',
'webkitFullscreenElement',
'webkitRequestFullscreen',
'webkitExitFullscreen',
'webkitfullscreenchange',
'webkitfullscreenerror',
'-webkit-full-screen',
];
var moz = [
'mozFullScreenEnabled',
'mozFullScreenElement',
'mozRequestFullScreen',
'mozCancelFullScreen',
'mozfullscreenchange',
'mozfullscreenerror',
'-moz-full-screen',
];
var ms = [
'msFullscreenEnabled',
'msFullscreenElement',
'msRequestFullscreen',
'msExitFullscreen',
'MSFullscreenChange',
'MSFullscreenError',
'-ms-fullscreen',
];
// so it doesn't throw if no window or document
var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
var vendor = (('fullscreenEnabled' in document && Object.keys(key)) ||
(webkit[0] in document && webkit) ||
(moz[0] in document && moz) ||
(ms[0] in document && ms) ||
[]);
var fscreen = {
requestFullscreen: function (element) { return element[vendor[key.requestFullscreen]](); },
requestFullscreenFunction: function (element) { return element[vendor[key.requestFullscreen]]; },
get exitFullscreen() { return document[vendor[key.exitFullscreen]].bind(document); },
get fullscreenPseudoClass() { return ":" + vendor[key.fullscreen]; },
addEventListener: function (type, handler, options) { return document.addEventListener(vendor[key[type]], handler, options); },
removeEventListener: function (type, handler, options) { return document.removeEventListener(vendor[key[type]], handler, options); },
get fullscreenEnabled() { return Boolean(document[vendor[key.fullscreenEnabled]]); },
set fullscreenEnabled(val) { },
get fullscreenElement() { return document[vendor[key.fullscreenElement]]; },
set fullscreenElement(val) { },
get onfullscreenchange() { return document[("on" + vendor[key.fullscreenchange]).toLowerCase()]; },
set onfullscreenchange(handler) { return document[("on" + vendor[key.fullscreenchange]).toLowerCase()] = handler; },
get onfullscreenerror() { return document[("on" + vendor[key.fullscreenerror]).toLowerCase()]; },
set onfullscreenerror(handler) { return document[("on" + vendor[key.fullscreenerror]).toLowerCase()] = handler; },
};
export default fscreen;
//# sourceMappingURL=fscreen.esm.js.map