]> git.proxmox.com Git - mirror_xterm.js.git/blame - addons/fullscreen/fullscreen.js
Make all add-ons CommonJS importable
[mirror_xterm.js.git] / addons / fullscreen / fullscreen.js
CommitLineData
c7f4658e
PK
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 */
3f455f90 13(function (fullscreen) {
bd215861
PK
14 if (typeof exports === 'object' && typeof module === 'object') {
15 /*
16 * CommonJS environment
17 */
18 module.exports = fullscreen.call(this);
19 } else if (typeof define == 'function') {
3f455f90
PK
20 /*
21 * Require.js is available
22 */
23 define(['../../src/xterm'], fullscreen);
24 } else {
25 /*
26 * Plain browser environment
bd215861 27 */
3f455f90
PK
28 fullscreen(this.Xterm);
29 }
30})(function (Xterm) {
31 Xterm.prototype.toggleFullscreen = function (fullscreen) {
32 var fn;
33
34 if (typeof fullscreen == 'undefined') {
35 fn = (this.element.classList.contains('fullscreen')) ? 'remove' : 'add';
36 } else if (!fullscreen) {
37 fn = 'remove';
38 } else {
39 fn = 'add';
40 }
41
42 this.element.classList[fn]('fullscreen');
43 };
bd215861 44});