]> git.proxmox.com Git - mirror_xterm.js.git/blob - addons/fullscreen/fullscreen.js
Merge pull request #53 from sourcelair/issue/52
[mirror_xterm.js.git] / addons / fullscreen / fullscreen.js
1 /*
2 * Fullscreen addon for xterm.js
3 *
4 * Implements the toggleFullscreen function.
5 *
6 * If the `fullscreen` argument has been supplied, then
7 * if it is true, the fullscreen mode gets turned on,
8 * if it is false or null, the fullscreen mode gets turned off.
9 *
10 * If the `fullscreen` argument has not been supplied, the
11 * fullscreen mode is being toggled.
12 */
13 (function (fullscreen) {
14 if (typeof exports === 'object' && typeof module === 'object') {
15 /*
16 * CommonJS environment
17 */
18 module.exports = fullscreen(require('../../src/xterm'));
19 } else if (typeof define == 'function') {
20 /*
21 * Require.js is available
22 */
23 define(['../../src/xterm'], fullscreen);
24 } else {
25 /*
26 * Plain browser environment
27 */
28 fullscreen(this.Xterm);
29 }
30 })(function (Xterm) {
31 var exports = {};
32
33 exports.toggleFullScreen = function (term, fullscreen) {
34 var fn;
35
36 if (typeof fullscreen == 'undefined') {
37 fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
38 } else if (!fullscreen) {
39 fn = 'remove';
40 } else {
41 fn = 'add';
42 }
43
44 term.element.classList[fn]('fullscreen');
45 };
46
47 Xterm.prototype.toggleFullscreen = function (fullscreen) {
48 exports.toggleFullScreen(this, fullscreen);
49 };
50
51 return exports;
52 });