Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 720641 (toolbar): s/command_output_view/output_view

We need to create a version of CommandOutputListView that just displays
a single bit of output. So this is a quick rename to make that more
logical
  • Loading branch information...
commit 7bf3ceedcbc534faf28361b0225f58d69e3cd5f9 1 parent ec8a21e
Joe Walker authored
4 lib/gcli/ui/display.js
View
@@ -11,7 +11,7 @@ var util = require('gcli/util');
var intro = require('gcli/ui/intro');
var Tooltip = require('gcli/ui/tooltip').Tooltip;
-var CommandOutputListView = require('gcli/ui/command_output_view').CommandOutputListView;
+var OutputTerminal = require('gcli/ui/output_terminal').OutputTerminal;
var Inputter = require('gcli/ui/inputter').Inputter;
var Completer = require('gcli/ui/completer').Completer;
var FocusManager = require('gcli/ui/focus').FocusManager;
@@ -92,7 +92,7 @@ exports.createView = function(options) {
var outputElement = util.createElement(doc, 'div');
outputElement.classList.add('gcli-display-output');
- var outputList = new CommandOutputListView(options, {
+ var outputList = new OutputTerminal(options, {
requisition: requisition,
element: outputElement
});
79 lib/gcli/ui/output_single.js
View
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2009-2011 Mozilla Foundation and contributors
+ * Licensed under the New BSD license. See LICENSE.txt or:
+ * http://opensource.org/licenses/BSD-3-Clause
+ */
+
+define(function(require, exports, module) {
+
+var util = require('gcli/util');
+var canon = require('gcli/canon');
+var outputViewCss = require('text!gcli/ui/output_view.css');
+
+
+/**
+ * A wrapper for a set of rows|command outputs.
+ * Register with the canon to be notified when commands have output to be
+ * displayed.
+ * @param options Object containing user customization properties, including:
+ * - commandOutputManager
+ * @param components Object that links to other UI components. GCLI provided:
+ * - element: Root element to populate
+ * - requisition (optional): A click/double-click to an input row causes the
+ * command to be sent to the input/executed if we know the requisition use
+ */
+function OutputSingle(options, components) {
+ this.requisition = components.requisition;
+
+ this.element = components.element;
+ this.element.classList.add('gcli-row-out');
+ this.element.setAttribute('aria-live', 'assertive');
+
+ this.commandOutputManager = options.commandOutputManager ||
+ canon.commandOutputManager;
+ this.commandOutputManager.onOutput.add(this.onOutputCommandChange, this);
+
+ if (outputViewCss != null) {
+ this.style = util.importCss(outputViewCss, this.element.ownerDocument);
+ }
+}
+
+/**
+ * Avoid memory leaks
+ */
+OutputSingle.prototype.destroy = function() {
+ if (this.style) {
+ this.style.parentNode.removeChild(this.style);
+ delete this.style;
+ }
+
+ delete this.element;
+ delete this.commandOutputManager;
+};
+
+/**
+ * Monitor for new command executions
+ */
+OutputSingle.prototype.onOutputCommandChange = function(ev) {
+ util.clearElement(this.element);
+
+ var output = ev.output.output;
+ var returnType = ev.output.command.returnType;
+
+ if (output != null) {
+ if (!(output instanceof HTMLElement)) {
+ var nodeName = (returnType === 'terminal') ? 'pre' : 'p';
+
+ var node = util.createElement(this.element.ownerDocument, nodeName);
+ util.setContents(node, output.toString());
+ output = node;
+ }
+
+ this.element.appendChild(output);
+ }
+};
+
+exports.OutputSingle = OutputSingle;
+
+
+});
0  lib/gcli/ui/command_output_view.html → lib/gcli/ui/output_terminal.html
View
File renamed without changes
72 lib/gcli/ui/command_output_view.js → lib/gcli/ui/output_terminal.js
View
@@ -11,8 +11,8 @@ var util = require('gcli/util');
var canon = require('gcli/canon');
var domtemplate = require('gcli/ui/domtemplate');
-var commandOutputViewCss = require('text!gcli/ui/command_output_view.css');
-var commandOutputViewHtml = require('text!gcli/ui/command_output_view.html');
+var outputViewCss = require('text!gcli/ui/output_view.css');
+var outputViewHtml = require('text!gcli/ui/output_terminal.html');
/**
@@ -26,7 +26,7 @@ var commandOutputViewHtml = require('text!gcli/ui/command_output_view.html');
* - requisition (optional): A click/double-click to an input row causes the
* command to be sent to the input/executed if we know the requisition use
*/
-function CommandOutputListView(options, components) {
+function OutputTerminal(options, components) {
this.element = components.element;
this.requisition = components.requisition;
@@ -35,18 +35,18 @@ function CommandOutputListView(options, components) {
this.commandOutputManager.onOutput.add(this.onOutputCommandChange, this);
var document = components.element.ownerDocument;
- if (commandOutputViewCss != null) {
- this.style = util.importCss(commandOutputViewCss, document);
+ if (outputViewCss != null) {
+ this.style = util.importCss(outputViewCss, document);
}
- this.template = util.toDom(document, commandOutputViewHtml);
- this.templateOptions = { allowEval: true, stack: 'command_output_view.html' };
+ this.template = util.toDom(document, outputViewHtml);
+ this.templateOptions = { allowEval: true, stack: 'output_terminal.html' };
}
/**
* Avoid memory leaks
*/
-CommandOutputListView.prototype.destroy = function() {
+OutputTerminal.prototype.destroy = function() {
if (this.style) {
this.style.parentNode.removeChild(this.style);
delete this.style;
@@ -59,9 +59,9 @@ CommandOutputListView.prototype.destroy = function() {
/**
* Monitor for new command executions
*/
-CommandOutputListView.prototype.onOutputCommandChange = function(ev) {
+OutputTerminal.prototype.onOutputCommandChange = function(ev) {
if (!ev.output.view) {
- ev.output.view = new CommandOutputView(ev.output, this);
+ ev.output.view = new OutputView(ev.output, this);
}
ev.output.view.onChange(ev);
};
@@ -69,19 +69,19 @@ CommandOutputListView.prototype.onOutputCommandChange = function(ev) {
/**
* Display likes to be able to control the height of its children
*/
-CommandOutputListView.prototype.setHeight = function(height) {
+OutputTerminal.prototype.setHeight = function(height) {
this.element.style.height = height + 'px';
};
-exports.CommandOutputListView = CommandOutputListView;
+exports.OutputTerminal = OutputTerminal;
/**
* Adds a row to the CLI output display
*/
-function CommandOutputView(outputData, commandOutputListView) {
+function OutputView(outputData, outputTerminal) {
this.outputData = outputData;
- this.listView = commandOutputListView;
+ this.outputTerminal = outputTerminal;
this.url = util.createUrlLookup(module);
@@ -96,17 +96,17 @@ function CommandOutputView(outputData, commandOutputListView) {
prompt: null
};
- var template = this.listView.template.cloneNode(true);
- domtemplate.template(template, this, this.listView.templateOptions);
+ var template = this.outputTerminal.template.cloneNode(true);
+ domtemplate.template(template, this, this.outputTerminal.templateOptions);
- this.listView.element.appendChild(this.elems.rowin);
- this.listView.element.appendChild(this.elems.rowout);
+ this.outputTerminal.element.appendChild(this.elems.rowin);
+ this.outputTerminal.element.appendChild(this.elems.rowout);
}
/**
* Only display a prompt if there is a command, otherwise, leave blank
*/
-Object.defineProperty(CommandOutputView.prototype, 'prompt', {
+Object.defineProperty(OutputView.prototype, 'prompt', {
get: function() {
return this.outputData.canonical ? '\u00bb' : '';
},
@@ -117,22 +117,22 @@ Object.defineProperty(CommandOutputView.prototype, 'prompt', {
* A single click on an invocation line in the console copies the command
* to the command line
*/
-CommandOutputView.prototype.copyToInput = function() {
- if (this.listView.requisition) {
- this.listView.requisition.update(this.outputData.typed);
+OutputView.prototype.copyToInput = function() {
+ if (this.outputTerminal.requisition) {
+ this.outputTerminal.requisition.update(this.outputData.typed);
}
};
/**
* A double click on an invocation line in the console executes the command
*/
-CommandOutputView.prototype.execute = function(ev) {
- if (this.listView.requisition) {
- this.listView.requisition.exec({ typed: this.outputData.typed });
+OutputView.prototype.execute = function(ev) {
+ if (this.outputTerminal.requisition) {
+ this.outputTerminal.requisition.exec({ typed: this.outputData.typed });
}
};
-CommandOutputView.prototype.hideOutput = function(ev) {
+OutputView.prototype.hideOutput = function(ev) {
this.elems.rowout.style.display = 'none';
this.elems.hide.classList.add('cmd_hidden');
this.elems.show.classList.remove('cmd_hidden');
@@ -140,7 +140,7 @@ CommandOutputView.prototype.hideOutput = function(ev) {
ev.stopPropagation();
};
-CommandOutputView.prototype.showOutput = function(ev) {
+OutputView.prototype.showOutput = function(ev) {
this.elems.rowout.style.display = 'block';
this.elems.hide.classList.remove('cmd_hidden');
this.elems.show.classList.add('cmd_hidden');
@@ -148,14 +148,14 @@ CommandOutputView.prototype.showOutput = function(ev) {
ev.stopPropagation();
};
-CommandOutputView.prototype.remove = function(ev) {
- this.listView.element.removeChild(this.elems.rowin);
- this.listView.element.removeChild(this.elems.rowout);
+OutputView.prototype.remove = function(ev) {
+ this.outputTerminal.element.removeChild(this.elems.rowin);
+ this.outputTerminal.element.removeChild(this.elems.rowout);
ev.stopPropagation();
};
-CommandOutputView.prototype.onChange = function(ev) {
+OutputView.prototype.onChange = function(ev) {
var document = this.elems.rowout.ownerDocument;
var duration = this.outputData.duration != null ?
'completed in ' + (this.outputData.duration / 1000) + ' sec ' :
@@ -196,15 +196,15 @@ CommandOutputView.prototype.onChange = function(ev) {
// We need to see the output of the latest command entered
// Certain browsers have a bug such that scrollHeight is too small
// when content does not fill the client area of the element
- var scrollHeight = Math.max(this.listView.element.scrollHeight,
- this.listView.element.clientHeight);
- this.listView.element.scrollTop =
- scrollHeight - this.listView.element.clientHeight;
+ var scrollHeight = Math.max(this.outputTerminal.element.scrollHeight,
+ this.outputTerminal.element.clientHeight);
+ this.outputTerminal.element.scrollTop =
+ scrollHeight - this.outputTerminal.element.clientHeight;
this.elems.throb.style.display = this.outputData.completed ? 'none' : 'block';
};
-exports.CommandOutputView = CommandOutputView;
+exports.OutputView = OutputView;
});
0  lib/gcli/ui/command_output_view.css → lib/gcli/ui/output_view.css
View
File renamed without changes
4 mozilla/gcli/ui/console.js
View
@@ -10,7 +10,7 @@ var Inputter = require('gcli/ui/inputter').Inputter;
var Completer = require('gcli/ui/completer').Completer;
var Tooltip = require('gcli/ui/tooltip').Tooltip;
var FocusManager = require('gcli/ui/focus').FocusManager;
-var CommandOutputListView = require('gcli/ui/command_output_view').CommandOutputListView;
+var OutputSingle = require('gcli/ui/output_single').OutputSingle;
var Requisition = require('gcli/cli').Requisition;
@@ -96,7 +96,7 @@ console.debug(options);
element: options.hintElement
});
- this.outputList = new CommandOutputListView(options, {
+ this.outputList = new OutputSingle(options, {
document: options.hintDocument,
requisition: this.requisition,
inputter: this.inputter,
6 node-main.js
View
@@ -164,7 +164,7 @@ function buildFirefox(destDir) {
'gcli/ui/arg_fetch.css',
'gcli/commands/help.css',
'gcli/ui/display.css',
- 'gcli/ui/command_output_view.css'
+ 'gcli/ui/output_view.css'
]);
// Package the JavaScript
@@ -291,8 +291,8 @@ function buildFirefox(destDir) {
'mozilla/gcli/ui/gclichrome.css',
{ value: '\n/* From: $GCLI/lib/gcli/ui/display.css */\n' },
'lib/gcli/ui/display.css',
- { value: '\n/* From: $GCLI/lib/gcli/ui/command_output_view.css */\n' },
- 'lib/gcli/ui/command_output_view.css'
+ { value: '\n/* From: $GCLI/lib/gcli/ui/output_view.css */\n' },
+ 'lib/gcli/ui/output_view.css'
],
filter: removeNonMozPrefixes,
dest: (destDir ? destDir + jsmDir : 'built/ff') + '/gclichrome.css'
Please sign in to comment.
Something went wrong with that request. Please try again.