Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: remoting/webapp/host_list.js

Issue 23441022: Add a reload button to host list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/resources/reload.webp ('k') | remoting/webapp/main.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_list.js
diff --git a/remoting/webapp/host_list.js b/remoting/webapp/host_list.js
index afc276b1bc1039c2edf5b27d96a01a6078842915..7b24b3da7358bbc6905ccb43b969e840eda0e36e 100644
--- a/remoting/webapp/host_list.js
+++ b/remoting/webapp/host_list.js
@@ -23,8 +23,12 @@ var remoting = remoting || {};
* @param {Element} errorMsg The HTML <div> to display error messages.
* @param {Element} errorButton The HTML <button> to display the error
* resolution action.
+ * @param {HTMLElement} loadingIndicator The HTML <span> to update while the
+ * host list is being loaded. The first element of this span should be
+ * the reload button.
*/
-remoting.HostList = function(table, noHosts, errorMsg, errorButton) {
+remoting.HostList = function(table, noHosts, errorMsg, errorButton,
+ loadingIndicator) {
/**
* @type {Element}
* @private
@@ -48,6 +52,11 @@ remoting.HostList = function(table, noHosts, errorMsg, errorButton) {
*/
this.errorButton_ = errorButton;
/**
+ * @type {HTMLElement}
+ * @private
+ */
+ this.loadingIndicator_ = loadingIndicator;
+ /**
* @type {Array.<remoting.HostTableEntry>}
* @private
*/
@@ -81,6 +90,15 @@ remoting.HostList = function(table, noHosts, errorMsg, errorButton) {
this.errorButton_.addEventListener('click',
this.onErrorClick_.bind(this),
false);
+ var reloadButton = this.loadingIndicator_.firstElementChild;
+ /** @type {remoting.HostList} */
+ var that = this;
+ /** @param {Event} event */
+ function refresh(event) {
+ event.preventDefault();
+ that.refresh(that.display.bind(that));
+ };
+ reloadButton.addEventListener('click', refresh, false);
};
/**
@@ -130,6 +148,7 @@ remoting.HostList.prototype.getHostForId = function(hostId) {
* @return {void} Nothing.
*/
remoting.HostList.prototype.refresh = function(onDone) {
+ this.loadingIndicator_.classList.add('loading');
/** @param {XMLHttpRequest} xhr The response from the server. */
var parseHostListResponse = this.parseHostListResponse_.bind(this, onDone);
/** @type {remoting.HostList} */
@@ -207,6 +226,7 @@ remoting.HostList.prototype.parseHostListResponse_ = function(onDone, xhr) {
this.lastError_ = remoting.Error.UNEXPECTED;
}
this.save_();
+ this.loadingIndicator_.classList.remove('loading');
onDone(this.lastError_ == '');
};
« no previous file with comments | « remoting/resources/reload.webp ('k') | remoting/webapp/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698