diff options
author | Christopher Lenz <cmlenz@apache.org> | 2009-01-14 22:09:30 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2009-01-14 22:09:30 +0000 |
commit | a97511cbd6254206f58a1ef77ce78e53211ebd9e (patch) | |
tree | e1884f17712b744db4c477355c580646ecfbf4f1 | |
parent | 892590e3a20c617b30ec8f89b0a895b753651e57 (diff) |
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.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@734531 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | share/www/config.html | 4 | ||||
-rw-r--r-- | share/www/replicator.html | 2 | ||||
-rw-r--r-- | share/www/script/futon.browse.js | 16 | ||||
-rw-r--r-- | share/www/script/futon.js | 4 |
4 files changed, 4 insertions, 22 deletions
diff --git a/share/www/config.html b/share/www/config.html index cc53ec3b..1341e063 100644 --- a/share/www/config.html +++ b/share/www/config.html @@ -26,7 +26,6 @@ specific language governing permissions and limitations under the License. <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 @@ specific language governing permissions and limitations under the License. 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); } }); diff --git a/share/www/replicator.html b/share/www/replicator.html index e873f141..02c09219 100644 --- a/share/www/replicator.html +++ b/share/www/replicator.html @@ -76,7 +76,6 @@ specific language governing permissions and limitations under the License. $("#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 @@ specific language governing permissions and limitations under the License. }); $("#records tbody tr").removeClass("odd").filter(":odd").addClass("odd"); $("#records tbody.footer td").text("Replication session " + resp.session_id); - $(document.body).removeClass("loading"); } }); }); diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js index 7528ee6e..b85e8691 100644 --- a/share/www/script/futon.browse.js +++ b/share/www/script/futon.browse.js @@ -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; diff --git a/share/www/script/futon.js b/share/www/script/futon.js index 493637ec..074451d6 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -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) { |