couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [17/50] [abbrv] git commit: updated refs/heads/1684-feature-db-updates to ea07223
Date Mon, 22 Jul 2013 10:25:34 GMT
Ajax loader helper

Added disableLoader & loaderClassname attribute to views, for showing ajax spinners. Included
default class and spinner image.
Added the loader to app-container as well, to run on the whole page while the routeObjects
load.

fixes #1802


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

Branch: refs/heads/1684-feature-db-updates
Commit: 17413bca6494f727e55dd641a2f70f167b8b5aed
Parents: 7cb6442
Author: suelockwood <deathbearbrown@gmail.com>
Authored: Thu Jun 6 11:12:38 2013 -0400
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Jun 10 10:22:58 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/api.js               |  22 ++++++++++++++++++----
 src/fauxton/assets/img/loader.gif    | Bin 0 -> 5193 bytes
 src/fauxton/assets/less/fauxton.less |   5 +++++
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/17413bca/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index e13a41d..58c413d 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -46,6 +46,10 @@ function(app, Fauxton) {
       return null;
     },
 
+    loaderClassname: 'loader',
+
+    disableLoader: false,
+
     hasRendered: function () {
       return !!this.__manager__.hasRendered;
     },
@@ -234,6 +238,8 @@ function(app, Fauxton) {
     crumbs: [],
     layout: "with_sidebar",
     apiUrl: null,
+    disableLoader: false,
+    loaderClassname: 'loader',
     renderedState: false,
     establish: function() {},
     route: function() {},
@@ -252,6 +258,11 @@ function(app, Fauxton) {
         masterLayout.setTemplate(this.layout);
       }
 
+      //add page loader. "app-container" shouldn't be overwritten. Even if a new index.underscore
is provided in settings.json
+      if (!this.disableLoader) {
+        $('#app-container').addClass(this.loaderClassname);
+      }
+
       masterLayout.clearBreadcrumbs();
       var crumbs = this.get('crumbs');
 
@@ -262,14 +273,17 @@ function(app, Fauxton) {
       }
 
       FauxtonAPI.when(this.establish()).done(function(resp) {
+        if (!this.disableLoader) {
+          $('#app-container').removeClass(this.loaderClassname);
+        }
         _.each(routeObject.getViews(), function(view, selector) {
           if(view.hasRendered()) { return; }
-
+          if (!view.disableLoader){ $(selector).addClass(view.loaderClassname);}
           masterLayout.setView(selector, view);
-
           FauxtonAPI.when(view.establish()).then(function(resp) {
+            if (!view.disableLoader) $(selector).removeClass(view.loaderClassname);
             masterLayout.renderView(selector);
-          }, function(resp) {
+            }, function(resp) {
             view.establishError = {
               error: true,
               reason: resp
@@ -286,7 +300,7 @@ function(app, Fauxton) {
             }
           });
         });
-      });
+      }.bind(this));
 
       if (this.get('apiUrl')) masterLayout.apiBar.update(this.get('apiUrl'));
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/17413bca/src/fauxton/assets/img/loader.gif
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/img/loader.gif b/src/fauxton/assets/img/loader.gif
new file mode 100644
index 0000000..96ff188
Binary files /dev/null and b/src/fauxton/assets/img/loader.gif differ

http://git-wip-us.apache.org/repos/asf/couchdb/blob/17413bca/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index 0bbde28..445b815 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -93,3 +93,8 @@ pre.view-code-error {
   height: auto;
   min-height: 50px;
 }
+
+.loader {
+  background: url('../img/loader.gif') center center no-repeat;
+  min-height:  100px;
+}


Mime
View raw message