You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2009/01/14 23:09:30 UTC

svn commit: r734531 - in /couchdb/trunk/share/www: config.html replicator.html script/futon.browse.js script/futon.js

Author: cmlenz
Date: Wed Jan 14 14:09:30 2009
New Revision: 734531

URL: http://svn.apache.org/viewvc?rev=734531&view=rev
Log:
Make the updating of the page-wide loading indicator in Futon both simpler and more robust by hooking into the jQuery global AJAX events support.

Modified:
    couchdb/trunk/share/www/config.html
    couchdb/trunk/share/www/replicator.html
    couchdb/trunk/share/www/script/futon.browse.js
    couchdb/trunk/share/www/script/futon.js

Modified: couchdb/trunk/share/www/config.html
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/config.html?rev=734531&r1=734530&r2=734531&view=diff
==============================================================================
--- couchdb/trunk/share/www/config.html (original)
+++ couchdb/trunk/share/www/config.html Wed Jan 14 14:09:30 2009
@@ -26,7 +26,6 @@
     <script src="script/futon.js?0.9.0"></script>
     <script>
       $(function() {
-        $(document.body).addClass("loading");
         $.couch.config({
           success: function(resp) {
             var sections = [];
@@ -58,16 +57,13 @@
               row.find("th").attr("rowspan", options.length);
             });
             $("#config tbody tr").removeClass("odd").filter(":odd").addClass("odd");
-            $(document.body).removeClass("loading");
 
             $("#config tbody td.value code").makeEditable({
               accept: function(newValue) {
-                $(document.body).addClass("loading");
                 var row = $(this).parents("tr").eq(0);
                 $.couch.config({
                   success: function(resp) {
                     row.find("td.value code").text(newValue);
-                    $(document.body).removeClass("loading");
                 }}, row.data("section"), row.data("option"), newValue);
               }
             });

Modified: couchdb/trunk/share/www/replicator.html
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/replicator.html?rev=734531&r1=734530&r2=734531&view=diff
==============================================================================
--- couchdb/trunk/share/www/replicator.html [utf-8] (original)
+++ couchdb/trunk/share/www/replicator.html [utf-8] Wed Jan 14 14:09:30 2009
@@ -76,7 +76,6 @@
           $("#records tbody.content").empty();
           var source = $("#from_local")[0].checked ? $("#from_name").val() : $("#from_url").val();
           var target = $("#to_local")[0].checked ? $("#to_name").val() : $("#to_url").val();
-          $(document.body).addClass("loading");
           $.couch.replicate(source, target, {
             success: function(resp) {
               $.each(resp.history, function(idx, record) {
@@ -86,7 +85,6 @@
               });
               $("#records tbody tr").removeClass("odd").filter(":odd").addClass("odd");
               $("#records tbody.footer td").text("Replication session " + resp.session_id);
-              $(document.body).removeClass("loading");
             }
           });
         });

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=734531&r1=734530&r2=734531&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Wed Jan 14 14:09:30 2009
@@ -39,7 +39,6 @@
 
       this.updateDatabaseListing = function(offset) {
         offset |= 0;
-        $(document.body).addClass("loading");
         var maxPerPage = parseInt($("#perpage").val(), 10);
 
         $.couch.allDbs({
@@ -47,9 +46,6 @@
             $("#paging a").unbind();
             $("#databases tbody.content").empty();
 
-            if (dbs.length == 0) {
-              $(document.body).removeClass("loading");
-            }
             var dbsOnPage = dbs.slice(offset, offset + maxPerPage);
 
             $.each(dbsOnPage, function(idx, dbName) {
@@ -64,9 +60,6 @@
                     .find("td.size").text($.futon.formatSize(info.disk_size)).end()
                     .find("td.count").text(info.doc_count).end()
                     .find("td.seq").text(info.update_seq);
-                  if (idx == dbsOnPage.length - 1) {
-                    $(document.body).removeClass("loading");
-                  }
                 }
               });
             });
@@ -426,7 +419,6 @@
         var viewNameParts = viewName.split("/");
         var designDocId = viewNameParts[1];
         var localViewName = viewNameParts[2];
-        $(document.body).addClass("loading");
         db.openDoc(["_design", designDocId].join("/"), {
           success: function(doc) {
             var numViews = 0;
@@ -448,7 +440,6 @@
                 page.isDirty = false;
                 $("#viewcode button.revert, #viewcode button.save")
                   .attr("disabled", "disabled");
-                $(document.body).removeClass("loading");
               }
             });
           }
@@ -466,7 +457,6 @@
       }
 
       this.updateDocumentListing = function(options) {
-        $(document.body).addClass("loading");
         if (options === undefined) options = {};
         if (options.limit === undefined) {
           options.limit = parseInt($("#perpage").val(), 10);
@@ -577,11 +567,9 @@
             "Showing " + firstNum + "-" + lastNum + " of " + totalNum +
             " row" + (firstNum != lastNum ? "s" : ""));
           $("#documents tbody tr:odd").addClass("odd");
-          $(document.body).removeClass("loading");
         }
         options.error = function(status, error, reason) {
           alert("Error: " + error + "\n\n" + reason);
-          $(document.body).removeClass("loading");
         }
 
         if (!viewName || viewName == "_all_docs") {
@@ -689,7 +677,6 @@
       }
 
       this.updateFieldListing = function() {
-        $(document.body).addClass("loading");
         $("#fields tbody.content").empty();
 
         function handleResult(doc, revs) {
@@ -728,7 +715,6 @@
           if (location.hash == "#source") {
             page.activateSourceView();
           }
-          $(document.body).removeClass("loading");
         }
 
         db.openDoc(docId, {revs_info: true,
@@ -768,11 +754,9 @@
       }
 
       this.saveDocument = function() {
-        $(document.body).addClass("loading");
         db.saveDoc(page.doc, {
           error: function(status, error, reason) {
             alert("Error: " + error + "\n\n" + reason);
-            $(document.body).removeClass("loading");
           },
           success: function(resp) {
             page.isDirty = false;

Modified: couchdb/trunk/share/www/script/futon.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.js?rev=734531&r1=734530&r2=734531&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.js (original)
+++ couchdb/trunk/share/www/script/futon.js Wed Jan 14 14:09:30 2009
@@ -107,6 +107,10 @@
     navigation: new Navigation()
   });
 
+  $(document)
+    .ajaxStart(function() { $(this.body).addClass("loading"); })
+    .ajaxStop(function() { $(this.body).removeClass("loading"); });
+
   $(function() {
     document.title = "Apache CouchDB - Futon: " + document.title;
     $.get("_sidebar.html", function(resp) {