From c7310c21fbc3634c375c5dab72de55d12fc64df9 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Oct 2016 00:11:47 +1100 Subject: Fullscreen fix, styling --- src/js/plyr.js | 29 +++++++++++++++++------------ src/less/plyr.less | 6 +++--- src/scss/plyr.scss | 6 +++--- 3 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/js/plyr.js b/src/js/plyr.js index 36b99fd2..e21c5ab7 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -581,22 +581,25 @@ (function() { // Determine the prefix var prefix = (function() { - if (!_is.undefined(document.cancelFullScreen)) { - return ''; + var value = false; + + if (_is.function(document.cancelFullScreen)) { + value = ''; } else { // Check for fullscreen support by vendor prefix - ['webkit', 'o', 'moz', 'ms', 'khtml'].forEach(function(prefix) { - if (!_is.undefined(document[prefix + 'CancelFullScreen'])) { - return prefix; - } else if (!_is.undefined(document.msExitFullscreen) && document.msFullscreenEnabled) { + ['webkit', 'o', 'moz', 'ms', 'khtml'].some(function(prefix) { + if (_is.function(document[prefix + 'CancelFullScreen'])) { + value = prefix; + return true; + } else if (_is.function(document.msExitFullscreen) && document.msFullscreenEnabled) { // Special case for MS (when isn't it?) - return 'ms'; + value = 'ms'; + return true; } }); } - // If we got this far, there's no support - return false; + return value; })(); _fullscreen = { @@ -625,9 +628,12 @@ if (!_support.fullscreen) { return false; } - if (_is.undefined(element)) { + if (!_is.htmlElement(element)) { element = document.body; } + + console.log(prefix); + return (prefix === '') ? element.requestFullScreen() : element[prefix + (prefix === 'ms' ? 'RequestFullscreen' : 'RequestFullScreen')](); }, cancelFullScreen: function() { @@ -988,7 +994,6 @@ } // Picture in picture button - console.log(_support.pip); if (_inArray(config.controls, 'pip') && _support.pip) { html.push( '