Index: remoting/webapp/base/js/message_window.js |
diff --git a/remoting/webapp/base/js/message_window.js b/remoting/webapp/base/js/message_window.js |
index f110e6f659a6162dd852f061f2497cb45bd0187d..3d8edaea248dd91a74f91a472b857cfd0a619e33 100644 |
--- a/remoting/webapp/base/js/message_window.js |
+++ b/remoting/webapp/base/js/message_window.js |
@@ -62,6 +62,21 @@ MessageWindowImpl.prototype.initButton_ = |
}; |
/** |
+ * Updates the button label text. |
+ * Hides the button if the label is null or undefined. |
+ * |
+ * @param{HTMLElement} button |
+ * @param{?string} label |
+ * @private |
+ */ |
+MessageWindowImpl.prototype.updateButton_ = function(button, label) { |
+ if (label) { |
+ button.innerText = label; |
+ } |
+ button.hidden = !Boolean(label); |
+}; |
+ |
+/** |
* Event-handler callback, invoked when the parent window supplies the |
* message content. |
* |
@@ -77,8 +92,8 @@ MessageWindowImpl.prototype.onMessage_ = function(event) { |
var message = /** @type {string} */ (event.data['message']); |
var infobox = /** @type {string} */ (event.data['infobox']); |
var buttonLabel = /** @type {string} */ (event.data['buttonLabel']); |
- /** @type {string} */ |
- var cancelButtonLabel = (event.data['cancelButtonLabel']); |
+ var cancelButtonLabel = /** @type {string} */ |
+ (event.data['cancelButtonLabel']); |
var showSpinner = /** @type {boolean} */ (event.data['showSpinner']); |
if (typeof(messageId) != 'number' || |
typeof(title) != 'string' || |
@@ -136,14 +151,37 @@ MessageWindowImpl.prototype.onMessage_ = function(event) { |
case 'update_message': |
Jamie
2015/05/09 01:17:00
How about renaming this message 'update' and havin
garykac
2015/05/11 21:34:16
Done.
|
var message = /** @type {string} */ (event.data['message']); |
+ var buttonLabel = /** @type {string} */ (event.data['buttonLabel']); |
+ var cancelButtonLabel = /** @type {string} */ |
+ (event.data['cancelButtonLabel']); |
+ var showSpinner = /** @type {boolean} */ (event.data['showSpinner']); |
+ // The update_message may leave the buttonLabel, cancelButtonLabel and |
+ // showSpinner values undefined to have them retain their current values. |
if (typeof(message) != 'string') { |
console.log('Bad update_message message:', event.data); |
break; |
} |
+ var button = document.getElementById('button-primary'); |
+ var cancelButton = document.getElementById('button-secondary'); |
var messageDiv = document.getElementById('message'); |
+ |
messageDiv.innerText = message; |
+ // If showSpinner was not specified, then don't change its state. |
+ if (typeof(showSpinner) == 'boolean') { |
+ if (showSpinner) { |
+ messageDiv.classList.add('waiting'); |
+ messageDiv.classList.add('prominent'); |
+ } else { |
+ messageDiv.classList.remove('waiting'); |
+ messageDiv.classList.remove('prominent'); |
+ } |
+ } |
+ |
+ this.updateButton_(button, buttonLabel); |
+ this.updateButton_(cancelButton, cancelButtonLabel); |
+ |
base.resizeWindowToContent(true); |
break; |