Skip to content

Commit 5b7afbd

Browse files
committed
Improved demo and added README.
1 parent 13b7b4a commit 5b7afbd

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
jQuery Fullscreen Plugin
2+
========================
3+
4+
5+
Description
6+
-----------
7+
8+
This jQuery plugin provides a simple to use mechanism to control the
9+
new fullscreen mode of modern browsers. Currently only newer Webkit-based
10+
browsers (Like Chrome) and Firefox provide this new fullscreen feature.
11+
12+
13+
Usage
14+
-----
15+
16+
### Entering Fullscreen mode ###
17+
18+
You can either switch the whole page or a single HTML element to fullscreen
19+
mode:
20+
21+
$(document).fullScreen(true);
22+
$("#myVideo").fullScreen(true);
23+
24+
This only works when the code was triggered by a user interaction (For
25+
example a onclick event on a button). Browsers don't allow entering
26+
fullscreen mode without user interaction.
27+
28+
### Exiting Fullscreen mode ###
29+
30+
Fullscreen mode is always exited via the document but this plugin allows
31+
it also via any HTML element. The owner document of the selected HTML
32+
element is used then:
33+
34+
$(document).fullScreen(false);
35+
$("#myVideo").fullScreen(false);
36+
37+
### Querying Fullscreen mode ###
38+
39+
Simply pass no argument to the `fullScreen` method to query the current
40+
state. The method returns `true` when fullscreen mode is active, `false`
41+
if not or `null` when the browser does not support fullscreen mode at all.
42+
So you can use this method also to display a fullscreen button only when the
43+
browser supports fullscreen mode:
44+
45+
$("#fullscreenButton").toggle($(document).fullScreen() != null))
46+
47+
### Toggling Fullscreen mode ###
48+
49+
The plugin provides another method for simple fullscreen mode toggling:
50+
51+
$(document).toggleFullScreen();

demo/index.html

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,32 @@
55
<title>jQuery Fullscreen Plugin demo</title>
66
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
77
<script type="text/javascript" src="../jquery.fullscreen-min.js"></script>
8+
<script type="text/javascript">
9+
10+
$(function() {
11+
12+
$(".fullscreen-supported").toggle($(document).fullScreen() != null);
13+
$(".fullscreen-not-supported").toggle($(document).fullScreen() == null);
14+
15+
});
16+
17+
</script>
818
</head>
919
<body>
10-
<button onclick="$(document).fullScreen(true)">Go Fullscreen</button>
11-
<button onclick="$(document).fullScreen(false)">Exit Fullscreen</button>
12-
<button onclick="$(document).toggleFullScreen()">Toggle Fullscreen</button>
13-
<button onclick="alert($(document).fullScreen())">Are we Fullscreen?</button>
20+
<h1>jQuery Fullscreen Plugin demo</h1>
21+
<div id="buttons">
22+
<button onclick="$(document).fullScreen(true)">Enter Fullscreen mode (Document)</button>
23+
<button onclick="$('#buttons').fullScreen(true)">Enter Fullscreen mode (Button panel)</button><br />
24+
<button onclick="$(document).fullScreen(false)">Exit Fullscreen mode</button><br />
25+
<button onclick="$(document).toggleFullScreen()">Toggle Fullscreen mode (Document)</button><br />
26+
<button onclick="alert($(document).fullScreen())">Query Fullscreen mode</button>
27+
</div>
28+
<p class="fullscreen-supported">
29+
Browser supports fullscreen mode.
30+
</p>
31+
<p class="fullscreen-not-supported">
32+
Browser does not support fullscreen mode.
33+
</p>
34+
1435
</body>
1536
</html>

0 commit comments

Comments
 (0)