source: trunk/termtv/js/overlay.js@ 19905

Last change on this file since 19905 was 17409, checked in by tbretz, 11 years ago
Enable strict mode.
File size: 1.6 KB
Line 
1'use strict';
2
3/**
4 * @class TTVOverlay
5 * @constructor
6 * @public
7 *
8 * This objects create a span which overlays the whole viewport. It fades
9 * in and displays a TTVPlayer at the center of the viewport.
10 *
11 * The given options are passed through to the created TTVDisplay object.
12 * The 'onclose' property is overwritten.
13 *
14 * @param {Object} options
15 * An object with options passed to the created TTVDisplay object.
16 */
17function TTVOverlay(options)
18{
19 var screen = document.createElement("span");
20 screen.setAttribute("style", "position:fixed;top:0px;left:0px;width:100%;height:100%;opacity:0;background-color:black;"); // right:500px;bottom:500px;
21
22 var body = document.getElementsByTagName("body")[0];
23 body.appendChild(screen);
24
25 var t = document.createElement("table");
26 t.setAttribute("style", "position:fixed;top:0px;left:0px;width:100%;height:100%");
27 var tr = document.createElement("tr");
28 var td = document.createElement("td");
29 td.align = "center";
30
31 options['onclose'] = function() { body.removeChild(t); body.removeChild(screen); },
32
33 body.appendChild(t);
34 t.appendChild(tr);
35 tr.appendChild(td);
36
37 function fadeIn()
38 {
39 screen.style.opacity = parseFloat(screen.style.opacity) + 0.03;
40 if (screen.style.opacity>0.79)
41 {
42 var disp = new TTVDisplay(options);
43 td.appendChild(disp);
44 return;
45 }
46
47 setTimeout(fadeIn, 1);
48 }
49
50 fadeIn();
51}
52
53// This is a hack to avoid that the closure compiler will rename
54// these functions
55window['TTVOverlay'] = TTVOverlay;
Note: See TracBrowser for help on using the repository browser.