Skip to content

Commit

Permalink
Merge #35 - Prevent TypeError: Document not active
Browse files Browse the repository at this point in the history
Pull-request: #35
Fixes: #34
  • Loading branch information
williamdes committed Apr 18, 2020
2 parents 24d23c0 + ea8adcb commit efd766e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions jquery.fullscreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @preserve jquery.fullscreen 1.1.5
* @preserve jquery.fullscreen 1.1.6
* https://github.com/kayahr/jquery-fullscreen-plugin
* Copyright (C) 2012-2013 Klaus Reimer <[email protected]>
* Licensed under the MIT license
Expand Down Expand Up @@ -61,10 +61,7 @@ function fullScreen(state)
}

// Check fullscreen state
state = !!doc["fullscreenElement"]
|| !!doc["msFullscreenElement"]
|| !!doc["webkitIsFullScreen"]
|| !!doc["mozFullScreen"];
state = fullScreenState(doc);
if (!state) return state;

// Return current fullscreen element or "true" if browser doesn't
Expand Down Expand Up @@ -100,11 +97,21 @@ function fullScreen(state)
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
|| (/** @type {?Function} */ doc["msExitFullscreen"])
|| (/** @type {?Function} */ doc["mozCancelFullScreen"]);
if (func) func.call(doc);
if (func && fullScreenState(doc)) func.call(doc);
return this;
}
}

/**
* Check fullscreen state
*
* @param {Document} doc The content document
* @return {Boolean}
*/
function fullScreenState(doc) {
return !!(doc["fullscreenElement"] || doc["msFullscreenElement"] || doc["webkitIsFullScreen"] || doc["mozFullScreen"]);
}

/**
* Toggles the fullscreen mode.
*
Expand Down

0 comments on commit efd766e

Please sign in to comment.