couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [2/2] git commit: updated refs/heads/master to f5a5862
Date Wed, 04 Dec 2013 14:32:53 GMT
Fauxton: Add viewHasRendered route event

This is used to clean up any left over spinners if a view has previously
been rendered


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f5a5862a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f5a5862a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f5a5862a

Branch: refs/heads/master
Commit: f5a5862a72214d292ccf5b61159bd10dedf5faff
Parents: 844ddfa
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed Dec 4 12:05:06 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Wed Dec 4 16:31:27 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/api.js | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f5a5862a/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 9d6ba08..a71c5f8 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -314,7 +314,10 @@ function(app, Fauxton) {
       FauxtonAPI.when(this.establish()).then(function(resp) {
         triggerBroadcast('afterEstablish');
         _.each(routeObject.getViews(), function(view, selector) {
-          if(view.hasRendered) { return; }
+          if(view.hasRendered) { 
+            triggerBroadcast('viewHasRendered', view, selector);
+            return;
+          }
 
           triggerBroadcast('beforeRender', view, selector);
           FauxtonAPI.when(view.establish()).then(function(resp) {
@@ -339,14 +342,6 @@ function(app, Fauxton) {
               masterLayout.renderView(selector);
           });
 
-          /*var hooks = masterLayout.hooks[selector];
-          var boundRoute = route;
-
-          _.each(hooks, function(hook){
-            if (_.any(hook.routes, function(route){return route == boundRoute;})){
-              hook.callback(view);
-            }
-          });*/
         });
       }.bind(this), function (resp) {
           if (!resp) { return; }
@@ -479,12 +474,23 @@ function(app, Fauxton) {
    }
   });
 
-  var viewSpinner;
-  FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
-    if (!routeObject.disableLoader) {
+  var removeRouteObjectSpinner = function () {
+    if (routeObjectSpinner) {
       routeObjectSpinner.stop();
       $('.spinner').remove();
     }
+  };
+
+  var removeViewSpinner = function () {
+    if (viewSpinner){
+      viewSpinner.stop();
+      $('.spinner').remove();
+    }
+  };
+
+  var viewSpinner;
+  FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+    removeRouteObjectSpinner();
 
     if (!view.disableLoader){ 
       var opts = {
@@ -506,9 +512,12 @@ function(app, Fauxton) {
   });
 
   FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
-    if (!view.disableLoader){
-      viewSpinner.stop();
-    }
+    removeViewSpinner();
+  });
+
+  FauxtonAPI.RouteObject.on('viewHasRendered', function () {
+    removeViewSpinner();
+    removeRouteObjectSpinner();
   });
 
   var extensions = _.extend({}, Backbone.Events);


Mime
View raw message