7 lines
1.8 KiB
JavaScript
7 lines
1.8 KiB
JavaScript
/*!
|
|
* screenfull
|
|
* v1.1.0 - 2013-09-06
|
|
* https://github.com/sindresorhus/screenfull.js
|
|
* (c) Sindre Sorhus; MIT License
|
|
*/(function(s,l){"use strict";var o=typeof Element!="undefined"&&"ALLOW_KEYBOARD_INPUT"in Element,n=function(){for(var e,u,c=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenchange","MSFullscreenerror"]],r=0,f=c.length,i={};f>r;r++)if(e=c[r],e&&e[1]in l){for(r=0,u=e.length;u>r;r++)i[c[0][r]]=e[r];return i}return!1}(),t={request:function(e){var u=n.requestFullscreen;e=e||l.documentElement,/5\.1[\.\d]* Safari/.test(navigator.userAgent)?e[u]():e[u](o&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){l[n.exitFullscreen]()},toggle:function(e){this.isFullscreen?this.exit():this.request(e)},onchange:function(){},onerror:function(){},raw:n};return n?(Object.defineProperties(t,{isFullscreen:{get:function(){return!!l[n.fullscreenElement]}},element:{enumerable:!0,get:function(){return l[n.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!l[n.fullscreenEnabled]}}}),l.addEventListener(n.fullscreenchange,function(e){t.onchange.call(t,e)}),l.addEventListener(n.fullscreenerror,function(e){t.onerror.call(t,e)}),s.screenfull=t,void 0):(s.screenfull=!1,void 0)})(window,document);
|