forked from nicekei/jQuery-html5-canvas-panorama-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddpanorama.fullscreen.js
43 lines (38 loc) · 1.03 KB
/
ddpanorama.fullscreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//code snippet from http://www.sitepoint.com/html5-full-screen-api/
var ddpfx = ["webkit", "moz", "ms", "o", ""];
function ddRunPrefixMethod(obj, method) {
var p = 0, m, t;
while (p < ddpfx.length && !obj[m]) {
m = method;
if (ddpfx[p] == "") {
m = m.substr(0,1).toLowerCase() + m.substr(1);
}
m = ddpfx[p] + m;
t = typeof obj[m];
if (t != "undefined") {
//console.log("m:"+m);
ddpfx = [ddpfx[p]];
return (t == "function" ? obj[m]() : obj[m]);
}
p++;
}
}
function ddLaunchFullScreen() {
ddRunPrefixMethod(document.documentElement, "RequestFullScreen");
}
function ddFullScreenEnabled()
{
return ddRunPrefixMethod(document, "FullScreen") || ddRunPrefixMethod(document, "IsFullScreen");
}
function ddCancelFullScreen()
{
ddRunPrefixMethod(document, "CancelFullScreen");
}
function ddBindFullScreenEvent(handler)
{
var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange";
$(document).on(screen_change_events, function ()
{
handler(ddFullScreenEnabled());
});
}