Skip to content

Commit

Permalink
Merge pull request #37 from williamdes/master
Browse files Browse the repository at this point in the history
Some updates for version 1.1.6
  • Loading branch information
kayahr authored Apr 27, 2020
2 parents 9438016 + 105ad2d commit 108a857
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 98 deletions.
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/demo
/externs
/bower.json
/.npmignore
/.gitignore
1 change: 0 additions & 1 deletion .travis.yml

This file was deleted.

File renamed without changes.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
jQuery Fullscreen Plugin
========================

[![npm version](https://badge.fury.io/js/jquery-fullscreen-plugin.svg)](https://badge.fury.io/js/jquery-fullscreen-plugin)

[![CDNJS](https://img.shields.io/cdnjs/v/jquery-fullscreen-plugin.svg)](https://cdnjs.com/libraries/jquery-fullscreen-plugin)


Description
-----------
Expand All @@ -15,13 +19,13 @@ Usage
-----

### Entering Fullscreen mode

You can either switch the whole page or a single HTML element to fullscreen
mode:

```js
$(document).fullScreen(true);
$("#myVideo").fullScreen(true);

```
This only works when the code was triggered by a user interaction (For
example a onclick event on a button). Browsers don't allow entering
fullscreen mode without user interaction.
Expand All @@ -32,10 +36,10 @@ fullscreen mode without user interaction.
Fullscreen mode is always exited via the document but this plugin allows
it also via any HTML element. The owner document of the selected HTML
element is used then:

```js
$(document).fullScreen(false);
$("#myVideo").fullScreen(false);

```

### Querying Fullscreen mode

Expand All @@ -45,41 +49,41 @@ browser doesn't support this) when fullscreen mode is active, `false` if not
active or `null` when the browser does not support fullscreen mode at all.
So you can use this method also to display a fullscreen button only when the
browser supports fullscreen mode:

```js
$("#fullscreenButton").toggle($(document).fullScreen() != null))

```

### Toggling Fullscreen mode

The plugin provides another method for simple fullscreen mode toggling:

```js
$(document).toggleFullScreen();

```

### Notifications

The plugin triggers a `fullscreenchange` event on the document when the
fullscreen mode has been changed. If the browser rejected a fullscreen
state change then the plugin triggers a `fullscreenerror` event on the
document. Example:

```js
$(document).bind("fullscreenchange", function() {
console.log("Fullscreen " + ($(document).fullScreen() ? "on" : "off"));
});

$(document).bind("fullscreenerror", function() {
alert("Browser rejected fullscreen change");
});

```

### Fullscreen iframe

Entering fullscreen mode from within an iframe is not allowed by default but
it can be enabled with a few attributes on the iframe:

```html
<iframe src="iframe.html" webkitAllowFullScreen mozAllowFullScreen allowFullScreen>
</iframe>

```
### Known issues

* In IE 11 an empty page is displayed when entering fullscreen from within an
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "jquery-fullscreen-plugin",
"homepage": "https://github.com/kayahr/jquery-fullscreen-plugin",
"main": "jquery.fullscreen.js",
"version": "1.1.4"
"version": "1.1.5"
}
54 changes: 0 additions & 54 deletions build.xml

This file was deleted.

2 changes: 1 addition & 1 deletion demo/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<title>Test iframe</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="../jquery.fullscreen-min.js"></script>
</head>
<body style="background:white">
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<title>jQuery Fullscreen Plugin demo</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="../jquery.fullscreen-min.js"></script>
<script>

Expand Down
4 changes: 1 addition & 3 deletions jquery.fullscreen-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 29 additions & 22 deletions jquery.fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
* Licensed under the MIT license
* (See http://www.opensource.org/licenses/mit-license)
*/

(function(jQuery) {

/**
* Sets or gets the fullscreen state.
*
*
* @param {boolean=} state
* True to enable fullscreen mode, false to disable it. If not
* specified then the current fullscreen state is returned.
* @return {boolean|Element|jQuery|null}
* When querying the fullscreen state then the current fullscreen
* element (or true if browser doesn't support it) is returned
* when browser is currently in full screen mode. False is returned
* if browser is not in full screen mode. Null is returned if
* browser doesn't support fullscreen mode at all. When setting
* the fullscreen state then the current jQuery selection is
* if browser is not in full screen mode. Null is returned if
* browser doesn't support fullscreen mode at all. When setting
* the fullscreen state then the current jQuery selection is
* returned for chaining.
* @this {jQuery}
*/
function fullScreen(state)
{
var e, func, doc;

// Do nothing when nothing was selected
if (!this.length) return this;

// We only use the first selected element because it doesn't make sense
// to fullscreen multiple elements.
e = (/** @type {Element} */ this[0]);

// Find the real element and the document (Depends on whether the
// document itself or a HTML element was selected)
if (e.ownerDocument)
Expand All @@ -46,7 +46,7 @@ function fullScreen(state)
doc = e;
e = doc.documentElement;
}

// When no state was specified then return the current state.
if (state == null)
{
Expand All @@ -59,14 +59,11 @@ function fullScreen(state)
{
return null;
}

// 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
// support this
return (/** @type {?Element} */ doc["fullscreenElement"])
Expand All @@ -76,7 +73,7 @@ function fullScreen(state)
|| (/** @type {?Element} */ doc["mozFullScreenElement"])
|| state;
}

// When state was specified then enter or exit fullscreen mode.
if (state)
{
Expand All @@ -86,7 +83,7 @@ function fullScreen(state)
|| (/** @type {?Function} */ e["webkitRequestFullScreen"])
|| (/** @type {?Function} */ e["msRequestFullscreen"])
|| (/** @type {?Function} */ e["mozRequestFullScreen"]);
if (func)
if (func)
{
func.call(e);
}
Expand All @@ -100,21 +97,31 @@ 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.
*
*
* @return {!jQuery}
* The jQuery selection for chaining.
* @this {jQuery}
*/
function toggleFullScreen()
{
return (/** @type {!jQuery} */ fullScreen.call(this,
return (/** @type {!jQuery} */ fullScreen.call(this,
!fullScreen.call(this)));
}

Expand Down Expand Up @@ -148,7 +155,7 @@ function fullScreenErrorHandler(event)
function installFullScreenHandlers()
{
var e, change, error;

// Determine event name
e = document;
if (e["webkitCancelFullScreen"])
Expand All @@ -166,7 +173,7 @@ function installFullScreenHandlers()
change = "mozfullscreenchange";
error = "mozfullscreenerror";
}
else
else
{
change = "fullscreenchange";
error = "fullscreenerror";
Expand Down
Binary file removed lib/compiler.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions fullscreen.jquery.json → package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "fullscreen",
"name": "jquery-fullscreen-plugin",
"title": "jQuery Fullscreen Plugin",
"description": "This jQuery plugin provides a simple to use mechanism to control the new fullscreen mode of modern browsers. Currently only newer Webkit-based browsers (Like Chrome) and Firefox provide this new fullscreen feature.",
"keywords": [
"fullscreen"
],
"version": "1.1.4",
"version": "1.1.5",
"author": {
"name": "Klaus Reimer",
"email": "k@ailis.de"
Expand Down

0 comments on commit 108a857

Please sign in to comment.