Skip to content

Instantly share code, notes, and snippets.

@L8D
Forked from oroce/test.js
Last active January 4, 2016 00:19
Show Gist options
  • Save L8D/8540768 to your computer and use it in GitHub Desktop.
Save L8D/8540768 to your computer and use it in GitHub Desktop.
var gimmeFullscreenMethod = function() {
'use strict';
var el = document.documentElement, open, cancel, video;
open = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
cancel = el.exitFullscreen || el.webkitExitFullscreen || el.mozExitFullscreen || el.msExitFullscreen;
if (open) {
return {
open: open,
cancel: cancel,
type: 'document'
};
}
video = document.createElement('video');
open = video.enterFullScreen || video.webkitEnterFullScreen || video.mozEnterFullScreen || video.msEnterFullScreen;
cancel = video.cancelFullScreen video.el.webkitCancelFullScreen || video.mozCancelFullScreen || video.msCancelFullScreen;
if (openMethod) {
return {
open: open,
cancel: cancel,
type: "video"
};
}
};
var fullscreen = gimmeFullscreenMethod();
if (fullscreen && fullscreen.type === "document") {
fullscreen.open.call(document.querySelector( ".video-wrapper-with-custom-controls" ));
// handle close button using `fullscreen.cancel` method
} else if (fullscreen && fullscreen.type === "video") {
fullscreen.open.call(document.querySelector('video'));
} else {
console.log('sad panda :(');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment