Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update to version 2.0.0

* Adds callback functions for individual requests.
* Clean up and standardize error handling.
  • Loading branch information...
commit 05e09ae04f269f7037d3920564b635f3bebf6278 1 parent 90b03a9
@bdougherty authored
View
9 README.md
@@ -10,7 +10,7 @@ BigScreen makes it easy to use full screen on your site or in your app. It smoot
## Download
-BigScreen is ~1 kb minified and gzipped. [Download it now](https://raw.github.com/bdougherty/BigScreen/master/bigscreen.min.js).
+BigScreen is ~1.4 kb minified and gzipped. [Download it now](https://raw.github.com/bdougherty/BigScreen/master/bigscreen.min.js).
## Supported Browsers
@@ -138,6 +138,13 @@ Safari 5.0 and iOS 4.2+ support putting `<video>` into full screen. `BigScreen.e
This function will report `false` if there is no child `<video>`, or if it is not possible to put a `<video>` in full screen. It will report `'maybe'` if it is possible, but the video's metadata has not been loaded, and `true` if it will be able to enter full screen.
+## Version History
+
+* 2.0.0 - 01/21/2013 - Add individual element callbacks and clean up error handling
+* 1.0.2 - 12/26/2012 - Use `webkitbeginfullscreen` and `webkitendfullscreen` on iOS instead of polling
+* 1.0.1 - 10/04/2012 - Fix for video controls bug in WebKit
+* 1.0.0 - 08/26/2012 - Initial Release
+
## Known Fullscreen API Issues
Safari 6.0 does not work properly when putting multiple elements into full screen. [Open Radar bug report](http://openradar.appspot.com/radar?id=1878403).
View
598 bigscreen.js
@@ -1,334 +1,274 @@
/*! BigScreen
- * v1.0.2 - 2013-01-20
+ * v1.1.0 - 2013-01-21
* https://github.com/bdougherty/BigScreen
* Copyright 2013 Brad Dougherty; Apache 2.0 License
*/
(function(window, document, iframe) {
- 'use strict';
-
- var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
-
- var fn = (function() {
- var map = [
- // spec
- {
- request: 'requestFullscreen',
- exit: 'exitFullscreen',
- enabled: 'fullscreenEnabled',
- element: 'fullscreenElement',
- change: 'fullscreenchange',
- error: 'fullscreenerror'
- },
- // new WebKit
- {
- request: 'webkitRequestFullscreen',
- exit: 'webkitExitFullscreen',
- enabled: 'webkitFullscreenEnabled',
- element: 'webkitFullscreenElement',
- change: 'webkitfullscreenchange',
- error: 'webkitfullscreenerror'
- },
- // older WebKit (Safari 5.1)
- {
- request: 'webkitRequestFullScreen',
- exit: 'webkitCancelFullScreen',
- element: 'webkitCurrentFullScreenElement',
- change: 'webkitfullscreenchange',
- error: 'webkitfullscreenerror'
- },
- // Firefox 10+
- {
- request: 'mozRequestFullScreen',
- exit: 'mozCancelFullScreen',
- enabled: 'mozFullScreenEnabled',
- element: 'mozFullScreenElement',
- change: 'mozfullscreenchange',
- error: 'mozfullscreenerror'
- }
- ];
-
- var fullscreen = false;
- var testElement = document.createElement('video');
-
- // Loop through each one and check to see if the request function exists
- for (var i = 0; i < map.length; i++) {
- if (map[i].request in testElement) {
- fullscreen = map[i];
-
- // Double-check that all functions/events exist and if not, delete them
- for (var item in fullscreen) {
- if (!('on' + fullscreen[item] in document) && !(fullscreen[item] in document) && !(fullscreen[item] in testElement)) {
- delete fullscreen[item];
- }
- }
-
- break;
- }
- }
-
- testElement = null;
-
- return fullscreen;
- }());
-
- // From Underscore.js 1.3.3
- // http://underscorejs.org
- function debounce(func, wait, immediate) {
- var timeout;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) {
- func.apply(context, args);
- }
- };
- var callNow = immediate && !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) {
- func.apply(context, args);
- }
- };
- }
-
- // Find a child <video> in the element passed.
- function getVideo(element) {
- var videoElement = null;
-
- if (element.tagName === 'VIDEO') {
- videoElement = element;
- }
- else {
- var videos = element.getElementsByTagName('video');
- if (videos[0]) {
- videoElement = videos[0];
- }
- }
-
- return videoElement;
- }
-
- var lastFullscreenVideo = null;
- var hasControls = null;
-
- // Check to see if there is a <video> and if the video has webkitEnterFullscreen, try it.
- // Metadata needs to be loaded for it to work, so load() if we need to.
- function videoEnterFullscreen(element) {
- var videoElement = getVideo(element);
-
- if (videoElement && videoElement.webkitEnterFullscreen) {
- try {
- // We can tell when it enters and exits full screen on iOS using these events.
- // Desktop Safari will fire the normal fullscreenchange event.
- videoElement.addEventListener('webkitbeginfullscreen', function onBeginFullscreen(event) {
- videoElement.removeEventListener('webkitbeginfullscreen', onBeginFullscreen, false);
- callOnEnter(videoElement);
- }, false);
-
- videoElement.addEventListener('webkitendfullscreen', function onEndFullscreen(event) {
- videoElement.removeEventListener('webkitendfullscreen', onEndFullscreen, false);
- callOnExit(videoElement);
- }, false);
-
- if (videoElement.readyState < videoElement.HAVE_METADATA) {
- videoElement.addEventListener('loadedmetadata', function onMetadataLoaded() {
- videoElement.removeEventListener('loadedmetadata', onMetadataLoaded, false);
- videoElement.webkitEnterFullscreen();
- hasControls = !!videoElement.getAttribute('controls');
- }, false);
- videoElement.load();
- }
- else {
- videoElement.webkitEnterFullscreen();
- hasControls = !!videoElement.getAttribute('controls');
- }
-
- lastFullscreenVideo = videoElement;
- videoElement.play();
- }
- catch (err) {
- bigscreen.onerror.call(videoElement);
- }
-
- return;
- }
-
- bigscreen.onerror.call(element);
- }
-
- // There is a bug in WebKit that will not fire a fullscreenchange event when the element exiting
- // is an iframe. This will listen for a window resize and fire exit if there is no current element.
- // Chrome bug: http://code.google.com/p/chromium/issues/detail?id=138368
- // Safari bug: rdar://11927884
- function resizeExitHack() {
- if (!bigscreen.element) {
- callOnExit();
- removeWindowResizeHack();
- }
- }
-
- function addWindowResizeHack() {
- if (iframe && fn.change === 'webkitfullscreenchange') {
- window.addEventListener('resize', resizeExitHack, false);
- }
- }
-
- function removeWindowResizeHack() {
- if (iframe && fn.change === 'webkitfullscreenchange') {
- window.removeEventListener('resize', resizeExitHack, false);
- }
- }
-
- var callOnEnter = debounce(function() {
- bigscreen.onenter.call(bigscreen);
- }, 500, true);
-
- var callOnExit = debounce(function() {
- // Fix a bug present in some versions of WebKit that will show the native controls when
- // exiting, even if they were not showing before.
- if (lastFullscreenVideo && !hasControls) {
- lastFullscreenVideo.setAttribute('controls', 'controls');
- lastFullscreenVideo.removeAttribute('controls');
- }
-
- lastFullscreenVideo = null;
- hasControls = null;
-
- bigscreen.onexit.call(bigscreen);
- }, 500, true);
-
- var bigscreen = {
- request: function(element) {
- element = element || document.documentElement;
-
- // iOS only supports webkitEnterFullscreen on videos.
- if (fn.request === undefined) {
- return videoEnterFullscreen(element);
- }
-
- // document.fullscreenEnabled is false, so try a video if there is one.
- if (iframe && document[fn.enabled] === false) {
- return videoEnterFullscreen(element);
- }
-
- // If we're in an iframe, it needs to have the allowfullscreen attribute in order for element full screen
- // to work. Safari 5.1 supports element full screen, but doesn't have document.webkitFullScreenEnabled,
- // so the only way to tell if it will work is to just try it.
- if (iframe && fn.enabled === undefined) {
- fn.enabled = 'webkitFullscreenEnabled';
-
- element[fn.request]();
-
- setTimeout(function() {
- if (!document[fn.element]) {
- document[fn.enabled] = false;
- videoEnterFullscreen(element);
- }
- else {
- document[fn.enabled] = true;
- }
- }, 250);
-
- return;
- }
-
- try {
- element[fn.request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
-
- // Safari 5.1 incorrectly states that it allows keyboard input when it doesn't
- if (!document[fn.element]) {
- element[fn.request]();
- }
- }
- catch (err) {
- bigscreen.onerror.call(element);
- }
- },
- exit: function() {
- removeWindowResizeHack(); // remove here if exit is called manually, so two onexit events are not fired
- document[fn.exit]();
- },
- toggle: function(element) {
- if (bigscreen.element) {
- bigscreen.exit();
- }
- else {
- bigscreen.request(element);
- }
- },
-
- // Mobile Safari and earlier versions of desktop Safari support sending a <video> into full screen.
- // Checks can't be performed to verify full screen capabilities unless we know about that element,
- // and it has loaded its metadata.
- videoEnabled: function(element) {
- if (bigscreen.enabled) {
- return true;
- }
-
- var video = getVideo(element);
-
- if (!video || video.webkitSupportsFullscreen === undefined) {
- return false;
- }
-
- return video.readyState < video.HAVE_METADATA ? 'maybe' : video.webkitSupportsFullscreen;
- },
-
- onenter: function() {},
- onexit: function() {},
- onerror: function() {}
- };
-
- try {
- Object.defineProperties(bigscreen, {
- element: {
- enumerable: true,
- get: function() {
- if (lastFullscreenVideo && lastFullscreenVideo.webkitDisplayingFullscreen) {
- return lastFullscreenVideo;
- }
-
- return document[fn.element] || null;
- }
- },
- enabled: {
- enumerable: true,
- get: function() {
- // Safari 5.1 supports full screen, but doesn't have a fullScreenEnabled property,
- // but it should work if not in an iframe.
- if (fn.exit === 'webkitCancelFullScreen' && !iframe) {
- return true;
- }
-
- return document[fn.enabled] || false;
- }
- }
- });
- }
- catch (err) {
- bigscreen.element = null;
- bigscreen.enabled = false;
- }
-
- if (fn.change) {
- document.addEventListener(fn.change, function(event) {
- if (bigscreen.element) {
- callOnEnter();
- addWindowResizeHack();
- }
- else {
- callOnExit();
- }
- }, false);
- }
-
- if (fn.error) {
- document.addEventListener(fn.error, function(event) {
- bigscreen.onerror.call(event.target);
- }, false);
- }
-
- window.BigScreen = bigscreen;
-
-}(window, document, self !== top));
+ "use strict";
+ var keyboardAllowed = typeof Element !== "undefined" && "ALLOW_KEYBOARD_INPUT" in Element;
+ var fn = function() {
+ var map = [ {
+ request: "requestFullscreen",
+ exit: "exitFullscreen",
+ enabled: "fullscreenEnabled",
+ element: "fullscreenElement",
+ change: "fullscreenchange",
+ error: "fullscreenerror"
+ }, {
+ request: "webkitRequestFullscreen",
+ exit: "webkitExitFullscreen",
+ enabled: "webkitFullscreenEnabled",
+ element: "webkitFullscreenElement",
+ change: "webkitfullscreenchange",
+ error: "webkitfullscreenerror"
+ }, {
+ request: "webkitRequestFullScreen",
+ exit: "webkitCancelFullScreen",
+ element: "webkitCurrentFullScreenElement",
+ change: "webkitfullscreenchange",
+ error: "webkitfullscreenerror"
+ }, {
+ request: "mozRequestFullScreen",
+ exit: "mozCancelFullScreen",
+ enabled: "mozFullScreenEnabled",
+ element: "mozFullScreenElement",
+ change: "mozfullscreenchange",
+ error: "mozfullscreenerror"
+ } ];
+ var fullscreen = false;
+ var testElement = document.createElement("video");
+ for (var i = 0; i < map.length; i++) {
+ if (map[i].request in testElement) {
+ fullscreen = map[i];
+ for (var item in fullscreen) {
+ if (item !== "change" && item !== "error" && !(fullscreen[item] in document) && !(fullscreen[item] in testElement)) {
+ delete fullscreen[item];
+ }
+ }
+ break;
+ }
+ }
+ testElement = null;
+ return fullscreen;
+ }();
+ function _getVideo(element) {
+ var videoElement = null;
+ if (element.tagName === "VIDEO") {
+ videoElement = element;
+ } else {
+ var videos = element.getElementsByTagName("video");
+ if (videos[0]) {
+ videoElement = videos[0];
+ }
+ }
+ return videoElement;
+ }
+ var lastVideoElement = null;
+ var hasControls = null;
+ var emptyFunction = function() {};
+ var elements = [];
+ function videoEnterFullscreen(element) {
+ var videoElement = _getVideo(element);
+ if (videoElement && videoElement.webkitEnterFullscreen) {
+ try {
+ videoElement.addEventListener("webkitbeginfullscreen", function onBeginFullscreen(event) {
+ videoElement.removeEventListener("webkitbeginfullscreen", onBeginFullscreen, false);
+ bigscreen.onchange(videoElement);
+ callOnEnter(videoElement);
+ }, false);
+ videoElement.addEventListener("webkitendfullscreen", function onEndFullscreen(event) {
+ videoElement.removeEventListener("webkitendfullscreen", onEndFullscreen, false);
+ bigscreen.onchange();
+ callOnExit();
+ }, false);
+ if (videoElement.readyState < videoElement.HAVE_METADATA) {
+ videoElement.addEventListener("loadedmetadata", function onMetadataLoaded() {
+ videoElement.removeEventListener("loadedmetadata", onMetadataLoaded, false);
+ videoElement.webkitEnterFullscreen();
+ hasControls = !!videoElement.getAttribute("controls");
+ }, false);
+ videoElement.load();
+ } else {
+ videoElement.webkitEnterFullscreen();
+ hasControls = !!videoElement.getAttribute("controls");
+ }
+ lastVideoElement = videoElement;
+ } catch (err) {
+ return callOnError("not_supported", element);
+ }
+ return true;
+ }
+ return callOnError(fn.request === undefined ? "not_supported" : "not_enabled", element);
+ }
+ function resizeExitHack() {
+ if (!bigscreen.element) {
+ callOnExit();
+ removeWindowResizeHack();
+ }
+ }
+ function addWindowResizeHack() {
+ if (iframe && fn.change === "webkitfullscreenchange") {
+ window.addEventListener("resize", resizeExitHack, false);
+ }
+ }
+ function removeWindowResizeHack() {
+ if (iframe && fn.change === "webkitfullscreenchange") {
+ window.removeEventListener("resize", resizeExitHack, false);
+ }
+ }
+ var callOnEnter = function(actualElement) {
+ var lastElement = elements[elements.length - 1];
+ if ((actualElement === lastElement.element || actualElement === lastVideoElement) && lastElement.hasEntered) {
+ return;
+ }
+ if (elements.length === 1) {
+ bigscreen.onenter(bigscreen.element);
+ }
+ lastElement.enter.call(lastElement.element, actualElement || lastElement.element);
+ lastElement.hasEntered = true;
+ };
+ var callOnExit = function() {
+ if (lastVideoElement && !hasControls) {
+ lastVideoElement.setAttribute("controls", "controls");
+ lastVideoElement.removeAttribute("controls");
+ }
+ lastVideoElement = null;
+ hasControls = null;
+ var element = elements.pop();
+ if (element) {
+ element.exit.call(element.element);
+ if (!bigscreen.element) {
+ elements.forEach(function(element) {
+ element.exit.call(element.element);
+ });
+ elements = [];
+ bigscreen.onexit();
+ }
+ }
+ };
+ var callOnError = function(reason, element) {
+ if (elements.length > 0) {
+ var obj = elements.pop();
+ element = element || obj.element;
+ obj.error.call(element, reason);
+ bigscreen.onerror(element, reason);
+ }
+ };
+ var bigscreen = {
+ request: function(element, enterCallback, exitCallback, errorCallback) {
+ element = element || document.documentElement;
+ elements.push({
+ element: element,
+ enter: enterCallback || emptyFunction,
+ exit: exitCallback || emptyFunction,
+ error: errorCallback || emptyFunction
+ });
+ if (fn.request === undefined) {
+ return videoEnterFullscreen(element);
+ }
+ if (iframe && document[fn.enabled] === false) {
+ return videoEnterFullscreen(element);
+ }
+ if (iframe && fn.enabled === undefined) {
+ fn.enabled = "webkitFullscreenEnabled";
+ element[fn.request]();
+ setTimeout(function() {
+ if (!document[fn.element]) {
+ document[fn.enabled] = false;
+ videoEnterFullscreen(element);
+ } else {
+ document[fn.enabled] = true;
+ }
+ }, 250);
+ return;
+ }
+ try {
+ if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
+ element[fn.request]();
+ } else {
+ element[fn.request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
+ }
+ setTimeout(function() {
+ if (!document[fn.element]) {
+ callOnError(iframe ? "not_enabled" : "not_allowed", element);
+ }
+ }, 100);
+ } catch (err) {
+ callOnError("not_enabled", element);
+ }
+ },
+ exit: function() {
+ removeWindowResizeHack();
+ document[fn.exit]();
+ },
+ toggle: function(element, enterCallback, exitCallback, errorCallback) {
+ if (bigscreen.element) {
+ bigscreen.exit();
+ } else {
+ bigscreen.request(element, enterCallback, exitCallback, errorCallback);
+ }
+ },
+ videoEnabled: function(element) {
+ if (bigscreen.enabled) {
+ return true;
+ }
+ element = element || document.documentElement;
+ var video = _getVideo(element);
+ if (!video || video.webkitSupportsFullscreen === undefined) {
+ return false;
+ }
+ return video.readyState < video.HAVE_METADATA ? "maybe" : video.webkitSupportsFullscreen;
+ },
+ onenter: emptyFunction,
+ onexit: emptyFunction,
+ onchange: emptyFunction,
+ onerror: emptyFunction
+ };
+ try {
+ Object.defineProperties(bigscreen, {
+ element: {
+ enumerable: true,
+ get: function() {
+ if (lastVideoElement && lastVideoElement.webkitDisplayingFullscreen) {
+ return lastVideoElement;
+ }
+ return document[fn.element] || null;
+ }
+ },
+ enabled: {
+ enumerable: true,
+ get: function() {
+ if (fn.exit === "webkitCancelFullScreen" && !iframe) {
+ return true;
+ }
+ return document[fn.enabled] || false;
+ }
+ }
+ });
+ } catch (err) {
+ bigscreen.element = null;
+ bigscreen.enabled = false;
+ }
+ if (fn.change) {
+ document.addEventListener(fn.change, function onFullscreenChange(event) {
+ bigscreen.onchange(bigscreen.element);
+ if (bigscreen.element) {
+ var previousElement = elements[elements.length - 2];
+ if (previousElement && previousElement.element === bigscreen.element) {
+ callOnExit();
+ } else {
+ callOnEnter(bigscreen.element);
+ addWindowResizeHack();
+ }
+ } else {
+ callOnExit();
+ }
+ }, false);
+ }
+ if (fn.error) {
+ document.addEventListener(fn.error, function onFullscreenError(event) {
+ callOnError("not_allowed");
+ }, false);
+ }
+ window["BigScreen"] = bigscreen;
+})(window, document, self !== top);
View
4 bigscreen.min.js
@@ -1,2 +1,2 @@
-// BigScreen v1.0.2 - 2013-01-20 - Apache 2.0 License
-(function(e,n,t){"use strict";function r(e,n,t){var r;return function(){var l=this,u=arguments,i=function(){r=null,t||e.apply(l,u)},c=t&&!r;clearTimeout(r),r=setTimeout(i,n),c&&e.apply(l,u)}}function l(e){var n=null;if("VIDEO"===e.tagName)n=e;else{var t=e.getElementsByTagName("video");t[0]&&(n=t[0])}return n}function u(e){var n=l(e);if(n&&n.webkitEnterFullscreen)try{n.addEventListener("webkitbeginfullscreen",function t(){n.removeEventListener("webkitbeginfullscreen",t,!1),b(n)},!1),n.addEventListener("webkitendfullscreen",function r(){n.removeEventListener("webkitendfullscreen",r,!1),m(n)},!1),n.readyState<n.HAVE_METADATA?(n.addEventListener("loadedmetadata",function u(){n.removeEventListener("loadedmetadata",u,!1),n.webkitEnterFullscreen(),d=!!n.getAttribute("controls")},!1),n.load()):(n.webkitEnterFullscreen(),d=!!n.getAttribute("controls")),f=n,n.play()}catch(i){E.onerror.call(n)}else E.onerror.call(e)}function i(){E.element||(m(),o())}function c(){t&&"webkitfullscreenchange"===s.change&&e.addEventListener("resize",i,!1)}function o(){t&&"webkitfullscreenchange"===s.change&&e.removeEventListener("resize",i,!1)}var a="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,s=function(){for(var e=[{request:"requestFullscreen",exit:"exitFullscreen",enabled:"fullscreenEnabled",element:"fullscreenElement",change:"fullscreenchange",error:"fullscreenerror"},{request:"webkitRequestFullscreen",exit:"webkitExitFullscreen",enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",change:"webkitfullscreenchange",error:"webkitfullscreenerror"},{request:"webkitRequestFullScreen",exit:"webkitCancelFullScreen",element:"webkitCurrentFullScreenElement",change:"webkitfullscreenchange",error:"webkitfullscreenerror"},{request:"mozRequestFullScreen",exit:"mozCancelFullScreen",enabled:"mozFullScreenEnabled",element:"mozFullScreenElement",change:"mozfullscreenchange",error:"mozfullscreenerror"}],t=!1,r=n.createElement("video"),l=0;e.length>l;l++)if(e[l].request in r){t=e[l];for(var u in t)"on"+t[u]in n||t[u]in n||t[u]in r||delete t[u];break}return r=null,t}(),f=null,d=null,b=r(function(){E.onenter.call(E)},500,!0),m=r(function(){f&&!d&&(f.setAttribute("controls","controls"),f.removeAttribute("controls")),f=null,d=null,E.onexit.call(E)},500,!0),E={request:function(e){if(e=e||n.documentElement,void 0===s.request)return u(e);if(t&&n[s.enabled]===!1)return u(e);if(t&&void 0===s.enabled)return s.enabled="webkitFullscreenEnabled",e[s.request](),setTimeout(function(){n[s.element]?n[s.enabled]=!0:(n[s.enabled]=!1,u(e))},250),void 0;try{e[s.request](a&&Element.ALLOW_KEYBOARD_INPUT),n[s.element]||e[s.request]()}catch(r){E.onerror.call(e)}},exit:function(){o(),n[s.exit]()},toggle:function(e){E.element?E.exit():E.request(e)},videoEnabled:function(e){if(E.enabled)return!0;var n=l(e);return n&&void 0!==n.webkitSupportsFullscreen?n.readyState<n.HAVE_METADATA?"maybe":n.webkitSupportsFullscreen:!1},onenter:function(){},onexit:function(){},onerror:function(){}};try{Object.defineProperties(E,{element:{enumerable:!0,get:function(){return f&&f.webkitDisplayingFullscreen?f:n[s.element]||null}},enabled:{enumerable:!0,get:function(){return"webkitCancelFullScreen"!==s.exit||t?n[s.enabled]||!1:!0}}})}catch(v){E.element=null,E.enabled=!1}s.change&&n.addEventListener(s.change,function(){E.element?(b(),c()):m()},!1),s.error&&n.addEventListener(s.error,function(e){E.onerror.call(e.target)},!1),e.BigScreen=E})(window,document,self!==top);
+// BigScreen v1.1.0 - 2013-01-21 - Apache 2.0 License
+(function(e,n,t){"use strict";function r(e){var n=null;if("VIDEO"===e.tagName)n=e;else{var t=e.getElementsByTagName("video");t[0]&&(n=t[0])}return n}function l(e){var n=r(e);if(n&&n.webkitEnterFullscreen){try{n.addEventListener("webkitbeginfullscreen",function t(){n.removeEventListener("webkitbeginfullscreen",t,!1),v.onchange(n),b(n)},!1),n.addEventListener("webkitendfullscreen",function l(){n.removeEventListener("webkitendfullscreen",l,!1),v.onchange(),E()},!1),n.readyState<n.HAVE_METADATA?(n.addEventListener("loadedmetadata",function u(){n.removeEventListener("loadedmetadata",u,!1),n.webkitEnterFullscreen(),d=!!n.getAttribute("controls")},!1),n.load()):(n.webkitEnterFullscreen(),d=!!n.getAttribute("controls")),s=n}catch(i){return g("not_supported",e)}return!0}return g(void 0===a.request?"not_supported":"not_enabled",e)}function u(){v.element||(E(),o())}function i(){t&&"webkitfullscreenchange"===a.change&&e.addEventListener("resize",u,!1)}function o(){t&&"webkitfullscreenchange"===a.change&&e.removeEventListener("resize",u,!1)}var c="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,a=function(){for(var e=[{request:"requestFullscreen",exit:"exitFullscreen",enabled:"fullscreenEnabled",element:"fullscreenElement",change:"fullscreenchange",error:"fullscreenerror"},{request:"webkitRequestFullscreen",exit:"webkitExitFullscreen",enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",change:"webkitfullscreenchange",error:"webkitfullscreenerror"},{request:"webkitRequestFullScreen",exit:"webkitCancelFullScreen",element:"webkitCurrentFullScreenElement",change:"webkitfullscreenchange",error:"webkitfullscreenerror"},{request:"mozRequestFullScreen",exit:"mozCancelFullScreen",enabled:"mozFullScreenEnabled",element:"mozFullScreenElement",change:"mozfullscreenchange",error:"mozfullscreenerror"}],t=!1,r=n.createElement("video"),l=0;e.length>l;l++)if(e[l].request in r){t=e[l];for(var u in t)"change"===u||"error"===u||t[u]in n||t[u]in r||delete t[u];break}return r=null,t}(),s=null,d=null,m=function(){},f=[],b=function(e){var n=f[f.length-1];(e!==n.element&&e!==s||!n.hasEntered)&&(1===f.length&&v.onenter(v.element),n.enter.call(n.element,e||n.element),n.hasEntered=!0)},E=function(){s&&!d&&(s.setAttribute("controls","controls"),s.removeAttribute("controls")),s=null,d=null;var e=f.pop();e&&(e.exit.call(e.element),v.element||(f.forEach(function(e){e.exit.call(e.element)}),f=[],v.onexit()))},g=function(e,n){if(f.length>0){var t=f.pop();n=n||t.element,t.error.call(n,e),v.onerror(n,e)}},v={request:function(e,r,u,i){if(e=e||n.documentElement,f.push({element:e,enter:r||m,exit:u||m,error:i||m}),void 0===a.request)return l(e);if(t&&n[a.enabled]===!1)return l(e);if(t&&void 0===a.enabled)return a.enabled="webkitFullscreenEnabled",e[a.request](),setTimeout(function(){n[a.element]?n[a.enabled]=!0:(n[a.enabled]=!1,l(e))},250),void 0;try{/5\.1[\.\d]* Safari/.test(navigator.userAgent)?e[a.request]():e[a.request](c&&Element.ALLOW_KEYBOARD_INPUT),setTimeout(function(){n[a.element]||g(t?"not_enabled":"not_allowed",e)},100)}catch(o){g("not_enabled",e)}},exit:function(){o(),n[a.exit]()},toggle:function(e,n,t,r){v.element?v.exit():v.request(e,n,t,r)},videoEnabled:function(e){if(v.enabled)return!0;e=e||n.documentElement;var t=r(e);return t&&void 0!==t.webkitSupportsFullscreen?t.readyState<t.HAVE_METADATA?"maybe":t.webkitSupportsFullscreen:!1},onenter:m,onexit:m,onchange:m,onerror:m};try{Object.defineProperties(v,{element:{enumerable:!0,get:function(){return s&&s.webkitDisplayingFullscreen?s:n[a.element]||null}},enabled:{enumerable:!0,get:function(){return"webkitCancelFullScreen"!==a.exit||t?n[a.enabled]||!1:!0}}})}catch(h){v.element=null,v.enabled=!1}a.change&&n.addEventListener(a.change,function(){if(v.onchange(v.element),v.element){var e=f[f.length-2];e&&e.element===v.element?E():(b(v.element),i())}else E()},!1),a.error&&n.addEventListener(a.error,function(){g("not_allowed")},!1),e.BigScreen=v})(window,document,self!==top);
View
2  component.json
@@ -1,6 +1,6 @@
{
"name": "BigScreen",
- "version": "1.0.2",
+ "version": "2.0.0",
"main": "./bigscreen.js",
"dependencies": {}
}
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "BigScreen",
- "version": "1.0.2",
+ "version": "2.0.0",
"description": "A simple library for using the JavaScript Full Screen API.",
"keywords": [
"fullscreen"
Please sign in to comment.
Something went wrong with that request. Please try again.