Sha256: d87d5c5c27fc8df88bb6989b9e2ba860a8576c79d18323c55a5b45a6dc035dc5

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

//= require term

;(function(BaseTerminal) {

  // Expose the main WebConsole namespace.
  var WebConsole = this.WebConsole = {};

  // Follow term.js example and expose inherits and EventEmitter.
  var inherits = WebConsole.inherits = BaseTerminal.inherits;
  var EventEmitter = WebConsole.EventEmitter = BaseTerminal.EventEmitter;

  var Terminal = WebConsole.Terminal = function(options) {
    if (typeof options === 'number') {
      return BaseTerminal.apply(this, arguments);
    }

    BaseTerminal.call(this, options || (options = {}));

    this.open();

    if (!(options.rows || options.cols) || !options.geometry) {
      this.fitScreen();
    }
  };

  // Make WebConsole.Terminal inherit from BaseTerminal (term.js).
  inherits(Terminal, BaseTerminal);

  Terminal.prototype.fitScreen = function() {
    var width  = Math.floor(this.element.clientWidth / this.cols);
    var height = Math.floor(this.element.clientHeight / this.rows);

    var rows = Math.floor(window.innerHeight / height);
    var cols = Math.floor(this.parent.clientWidth / width);

    this.resize(cols, rows);

    return [cols, rows];
  };

}).call(this, Terminal);

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
web-console-2.0.0 lib/assets/javascripts/web_console.js
web-console-2.0.0.beta4 lib/assets/javascripts/web_console.js
web-console-2.0.0.beta3 lib/assets/javascripts/web_console.js
web-console-rails3-1.0.4 lib/assets/javascripts/web_console.js
web-console-1.0.4 lib/assets/javascripts/web_console.js
web-console-rails3-1.0.3 lib/assets/javascripts/web_console.js
web-console-1.0.3 lib/assets/javascripts/web_console.js
web-console-1.0.2 lib/assets/javascripts/web_console.js
web-console-rails3-1.0.1 lib/assets/javascripts/web_console.js
web-console-1.0.1 lib/assets/javascripts/web_console.js
web-console-rails3-1.0.0 lib/assets/javascripts/web_console.js
web-console-1.0.0 lib/assets/javascripts/web_console.js
web-console-rails3-0.4.1 lib/assets/javascripts/web_console.js
web-console-0.4.0 lib/assets/javascripts/web_console.js