-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullScreen.min.js
1 lines (1 loc) · 2.14 KB
/
fullScreen.min.js
1
var fullScreen=function(a,b,c){function p(){return b.className+="fullSreenNotEnabled",{requestFullScreen:Function.prototype,cancelFullScreen:Function.prototype,fullscreenchange:Function.prototype,addEventListener:Function.prototype,fullScreenElement:c,fullScreenEnabled:!1,fullScreen:!1}}function r(){var a=h.call(arguments),b=[],c=a[0],d="_"===c[0];return a[1].forEach(function(a){d?b.push(q(a,c.replace("_",""))):b.push(q(c.replace("_",""),a))}),b}function s(){var d=[],h=[],k=!1;return f.forEach(function(a){d=d.concat(r(a,g))}),d.forEach(function(b){var d=q(n,b);c!==a[d]&&(i[j[b.toLowerCase()]]=d,k=!0)}),e.forEach(function(a){h=h.concat(r(a,g))}),h.forEach(function(a){var d=q(n,a);c!==b[d]&&(i[j[a.toLowerCase()]]=d,k=!0)}),k}var l,m,n,o,d=["ms","o","","webkit","moz"],e=["request_"],f=["cancel_","_element","_enabled","_","is_"],g=["fullscreen","fullScreen"],h=Array.prototype.slice,i={},j={fullscreenenabled:"fullScreenEnabled",fullscreenelement:"fullScreenElement",requestfullscreen:"requestFullScreen",cancelfullscreen:"cancelFullScreen",fullscreen:"fullScreen",isfullscreen:"fullScreen"},k=[];if(!Array.prototype.forEach||!a.querySelector)return p();var q=function(){var a={};return function(b,c){return a[c]||(a[c]=""+c.substring(0,1).toUpperCase()+c.substring(1)),b.length?b+a[c]:c}}();for(m=d.length;n=d[--m];)if(s(n)){o=n;break}if(!i.fullScreenEnabled)return p();l={requestFullScreen:function(a){(a||t)[i.requestFullScreen]()},cancelFullScreen:function(){a[i.cancelFullScreen]()},fullScreenElement:c,fullScreenEnabled:!0,fullScreen:!1,fullscreenchange:function(a,b){k.push([a,b])},addEventListener:function(a,b,c){var d,e;a&&(d=b||"click",e=c||document.body,a.addEventListener(d,function(){l.fullScreen?l.cancelFullScreen():l.requestFullScreen(e)}))}},a.addEventListener(o+"fullscreenchange",function(){l.fullScreenElement=a[i.fullScreenElement],l.fullScreen=!!l.fullScreenElement,k.forEach(function(a){a[0].call(a[1]||window,l.fullScreen)})}),document.documentElement.classList.add("fullScreenEnabled");var t=a.querySelector("#fullScreenElement");return h.call(a.querySelectorAll(".fullScreenToggle")).forEach(function(a){l.addEventListener(a)}),l}(document,document.body);