Better handling of clearing the error in the list callback.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Nov 2010 17:54:21 +0000 (12:54 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Nov 2010 17:54:21 +0000 (12:54 -0500)
web_frontend/main.js

index c4f9308336ac30918d5e50d2ebf895dc100b94b6..e030c1cbece77834e99392a77dda98c2c473ae2d 100644 (file)
@@ -30,6 +30,12 @@ armadillo.App = function() {
       this.hashChanged_, false, this);
 
   this.clearError(false);
+  /**
+   * If this is the first load, we don't want to flash the error animating
+   * out. This will be set to true in the list callback.
+   * @type  {bool}
+   */
+  this.initialized_ = false;
 
   var version = goog.string.format('Armadillo %d.%d (%d)',
       armadillo.Version.MAJOR, armadillo.Version.MINOR,
@@ -61,7 +67,7 @@ armadillo.App.prototype.list = function(path) {
       app.showError(data['message']);
       return;  // Error.
     } else {
-      app.clearError();
+      app.clearError(app.initialized_);
     }
 
     // Update the listing.
@@ -80,6 +86,8 @@ armadillo.App.prototype.list = function(path) {
       var fileObject = new armadillo.File(file, path);
       goog.dom.appendChild(list, fileObject.draw());
     });
+
+    app.initialized_ = true;
   }
   this.sendRequest('list', {'path':path}, callback);
 };
@@ -167,7 +175,9 @@ armadillo.App.prototype.clearError = function(animate) {
     anim.play();
   else
     anim.hide();
-  goog.dom.setTextContent(elm, '');
+  goog.events.listenOnce(anim, goog.fx.Animation.EventType.END, function() {
+    goog.dom.setTextContent(elm, '');
+  });
 };
 
 /**