hterm: Add optional timeout parameter to Terminal.showOverlay.
BUG=none
TEST=test_harness.html, 55/55 tests passed.
Change-Id: I79a2a11d746ae024b8c42d3c856e48d7be6acfea
Reviewed-on: https://gerrit.chromium.org/gerrit/16765
Reviewed-by: Marius Schilder <mschilder@google.com>
Commit-Ready: Marius Schilder <mschilder@google.com>
Reviewed-by: Zelidrag Hornung <zelidrag@chromium.org>
Commit-Ready: Robert Ginda <rginda@chromium.org>
Tested-by: Robert Ginda <rginda@chromium.org>
diff --git a/hterm/js/terminal.js b/hterm/js/terminal.js
index 5ebcbea..df7a85e 100644
--- a/hterm/js/terminal.js
+++ b/hterm/js/terminal.js
@@ -1629,7 +1629,20 @@
}, 0);
};
-hterm.Terminal.prototype.showOverlay = function(msg) {
+/**
+ * Show the terminal overlay for a given amount of time.
+ *
+ * The terminal overlay appears in inverse video in a large font, centered
+ * over the terminal. You should probably keep the overlay message brief,
+ * since it's in a large font and you probably aren't going to check the size
+ * of the terminal first.
+ *
+ * @param {string} msg The text (not HTML) message to display in the overlay.
+ * @param {number} opt_timeout The amount of time to wait before fading out
+ * the overlay. Defaults to 1.5 seconds. Pass null to have the overlay
+ * stay up forever (or until the next overlay).
+ */
+hterm.Terminal.prototype.showOverlay = function(msg, opt_timeout) {
if (!this.overlayNode_) {
if (!this.div_)
return;
@@ -1665,6 +1678,9 @@
if (this.overlayTimeout_)
clearTimeout(this.overlayTimeout_);
+ if (opt_timeout === null)
+ return;
+
this.overlayTimeout_ = setTimeout(function() {
self.overlayNode_.style.opacity = '0';
setTimeout(function() {
@@ -1672,7 +1688,7 @@
self.overlayTimeout_ = null;
self.overlayNode_.style.opacity = '0.75';
}, 200);
- }, 1500);
+ }, opt_timeout || 1500);
};
hterm.Terminal.prototype.overlaySize = function() {