aboutsummaryrefslogtreecommitdiffstats
path: root/html/js/fullscreen.js
blob: ce830bb9c1a02a110b2bbc4596dfff0d07f7f512 (plain) (blame)
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
44
45
46

function endFullScreen(oncancel) {
    if (!RunPrefixMethod(document, "FullScreen") && !RunPrefixMethod(document, "IsFullScreen")) {
        oncancel();
    }
}
function fullScreen(e, oncancel) {
    if (RunPrefixMethod(document, "FullScreen") || RunPrefixMethod(document, "IsFullScreen")) {
        RunPrefixMethod(document, "CancelFullScreen");
    }
    else {
        RunPrefixMethod(e, "RequestFullScreen");
        e.setAttribute("width", screen.width);
        e.setAttribute("height", screen.height);
    }
    if (arguments.length > 1) {
        var f = function () { endFullScreen(oncancel); };
        document.addEventListener("fullscreenchange", f, false);
        document.addEventListener("mozfullscreenchange", f, false);
        document.addEventListener("webkitfullscreenchange", f, false);
    }
}

var pfx = ["webkit", "moz", "ms", "o", ""];
function RunPrefixMethod(obj, method) {

    var p = 0, m, t;
    while (p < pfx.length && !obj[m]) {
        m = method;
        if (pfx[p] == "") {
            m = m.substr(0, 1).toLowerCase() + m.substr(1);
        }
        m = pfx[p] + m;
        t = typeof obj[m];
        if (t != "undefined") {
            pfx = [pfx[p]];
            return (t == "function" ? obj[m]() : obj[m]);
        }
        p++;
    }
}

function isFullScreen() {
    var fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled;
    return fullscreenEnabled;
}