Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Refactoring in Futon to clean up interactions between specific pages …
…and the navigation. Also, switched some graphics over to PNGs with alpha-transparency (screw you IE6), and added a button for removing databases from the recent databases list.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@733104 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cmlenz committed Jan 9, 2009
1 parent af89d8e commit 04ddce3602d34b16642237098b2c1f1ec86fa8ba
Showing 28 changed files with 193 additions and 112 deletions.
@@ -18,48 +18,3 @@
<span id="version">?</span>
</div>
</div>
<script type="text/javascript">
function updateNavigation(path, queryString) {
function fixupPath(path) { // hack for IE/Win
return (path.charAt(0) != "/") ? ("/" + path) : path;
}
if (!path) {
path = location.pathname;
if (!queryString) {
queryString = location.search;
}
} else if (!queryString) {
queryString = "";
}
var href = fixupPath(path + queryString);
$("#nav li").removeClass("selected");
$("#nav li a").each(function() {
if (fixupPath(this.pathname) + this.search != href) return;
$(this).parent("li").addClass("selected").parents("li").addClass("selected");
});
}

function updateRecentDatabasesList() {
$("#dbs").empty();
var recentDbs = $.cookies.get("recent", "").split(",");
recentDbs.sort();
$.each(recentDbs, function(idx, name) {
if (name) {
$("#dbs").append("<li><a href='database.html?" +
encodeURIComponent(name) + "'>" + name +
"</a></li>");
}
});
}

$(function() {
document.title = "Apache CouchDB - Futon: " + document.title;
$.couch.info({
success: function(info, status) {
$("#version").text(info.version);
}
});
updateRecentDatabasesList();
updateNavigation();
});
</script>
@@ -22,13 +22,10 @@
<script src="script/jquery.js?1.2.6"></script>
<script src="script/jquery.cookies.js?0.9.0"></script>
<script src="script/jquery.couch.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script>
$(document).ready(function() {
$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");
});

$(document.body).addClass("loading");
$.couch.config({
success: function(resp) {
@@ -23,14 +23,11 @@
<script src="script/jquery.cookies.js?0.9.0"></script>
<script src="script/jquery.couch.js?0.9.0"></script>
<script src="script/couch.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script src="script/couch_test_runner.js"></script>
<script>
$(function() {
$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");
});

updateTestsListing();
$("#toolbar button.run").click(runAllTests);
$("#toolbar button.load").click(function() {
@@ -25,23 +25,15 @@
<script src="script/jquery.dialog.js?0.9.0"></script>
<script src="script/jquery.resizer.js?0.9.0"></script>
<script src="script/jquery.suggest.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/browse.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script>
var page = new CouchDatabasePage();

$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");

var recentDbs = $.cookies.get("recent", "").split(",");
if ($.inArray(page.db.name, recentDbs) == -1) {
recentDbs.unshift(page.db.name);
if (recentDbs.length > 10) recentDbs.length = 10;
$.cookies.set("recent", recentDbs.join(","));
updateRecentDatabasesList();
}

updateNavigation(location.pathname, "?" + page.db.name);
$.futon.navigation.ready(function() {
this.addDatabase(page.db.name);
this.updateSelection(location.pathname, "?" + page.db.name);
});

$(function() {
@@ -91,6 +83,7 @@

$("#switch select").change(function() {
var viewName = $(this).val();
console.log(viewName);
if (!viewName) $.cookies.remove(page.db.name + ".view");
location.href = "?" + encodeURIComponent(page.db.name) +
(viewName ? "/" + encodeURIComponent(viewName) : "");
@@ -118,7 +111,7 @@ <h1>
<div id="content">
<div id="switch">
<label>Select view: <select autocomplete="false">
<option value="">All documents</option>
<option value="_all_docs">All documents</option>
<option value="_design_docs">Design documents</option>
<option value="_slow_view">Custom query…</option>
</select></label>
@@ -25,20 +25,21 @@
<script src="script/jquery.dialog.js?0.9.0"></script>
<script src="script/jquery.form.js?0.9.0"></script>
<script src="script/jquery.resizer.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/browse.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script>
var page = new CouchDocumentPage();

$(function() {
$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");

updateNavigation(
location.pathname.replace(/document\.html/, "database.html"),
"?" + page.db.name);
});
$.futon.navigation.ready(function() {
this.addDatabase(page.db.name);
this.updateSelection(
location.pathname.replace(/document\.html/, "database.html"),
"?" + page.db.name
);
});

$(function() {
$("h1 a.dbname").text(page.dbName)
.attr("href", "database.html?" + encodeURIComponent(page.db.name));
$("h1 strong").text(page.docId);
BIN -520 Bytes image/add.gif
Deleted file not rendered
BIN +709 Bytes image/add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -13.2 KB image/compact.gif
Deleted file not rendered
BIN +28.1 KB image/compact.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -257 Bytes image/delete-mini.gif
Deleted file not rendered
BIN +418 Bytes image/delete-mini.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -544 Bytes image/delete.gif
Deleted file not rendered
BIN +718 Bytes image/delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -538 Bytes image/load.gif
Deleted file not rendered
BIN +780 Bytes image/load.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -236 Bytes image/run-mini.gif
Deleted file not rendered
BIN +478 Bytes image/run-mini.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -489 Bytes image/run.gif
Deleted file not rendered
BIN +718 Bytes image/run.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -548 Bytes image/running.gif
Deleted file not rendered
BIN +284 Bytes image/running.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN -537 Bytes image/save.gif
Deleted file not rendered
BIN +843 Bytes image/save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -23,17 +23,17 @@
<script src="script/jquery.cookies.js?0.9.0"></script>
<script src="script/jquery.couch.js?0.9.0"></script>
<script src="script/jquery.dialog.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/browse.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script>
var page = new CouchIndexPage();
$(document).ready(function() {
$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");
if (!/index\.html$/.test(location.pathname)) {
updateNavigation(location.pathname + "index.html");
}
});
if (!/index\.html$/.test(location.pathname)) {
$.futon.navigation.ready(function() {
this.updateSelection(location.pathname + "index.html");
});
}
var dbsPerPage = $.cookies.get("perpage");
if (dbsPerPage) $("#perpage").val(dbsPerPage);
$("#perpage").change(function() {
@@ -22,13 +22,10 @@
<script src="script/jquery.js?1.2.6"></script>
<script src="script/jquery.cookies.js?0.9.0"></script>
<script src="script/jquery.couch.js?0.9.0"></script>
<script src="script/futon.js?0.9.0"></script>
<script src="script/pprint.js?0.9.0"></script>
<script>
$(document).ready(function() {
$.get("_sidebar.html", function(resp) {
$(resp).insertAfter("#wrap");
});

$("fieldset input[type=radio]").click(function() {
var radio = this;
var fieldset = $(this).parents("fieldset").get(0);
@@ -107,7 +107,10 @@ function CouchDatabasePage() {
viewName = decodeURIComponent(viewName);
$.cookies.set(dbName + ".view", viewName);
} else {
viewName = $.cookies.get(dbName + ".view") || "";
viewName = $.cookies.get(dbName + ".view", "");
if (viewName) {
location.href = "database.html?" + dbName + "/" + viewName;
}
}
var db = $.couch.db(dbName);

@@ -157,15 +160,7 @@ function CouchDatabasePage() {
$("#dbs li").filter(function(index) {
return $("a", this).text() == dbName;
}).remove();

// remove database from recent databases list
var recentDbs = $.cookies.get("recent", "").split(",");
var recentIdx = $.inArray(db.name, recentDbs)
if (recentIdx >= 0) {
recentDbs.splice(recentIdx, 1);
$.cookies.set("recent", recentDbs.join(","));
updateRecentDatabasesList();
}
$.futon.navigation.removeDatabase(dbName);
}
}
});
@@ -200,6 +195,11 @@ function CouchDatabasePage() {
.bind("textInput", updateDirtyState);
}
});
} else if (viewName == "_slow_view") {
page.updateViewEditor(
$.cookies.get(db.name + ".map"),
$.cookies.get(db.name + ".reduce", "")
);
}
}

@@ -252,11 +252,7 @@ function CouchDatabasePage() {
},
success: function(resp) {
var viewCode = resp.views[localViewName];
$("#viewcode_map").val(viewCode.map);
$("#viewcode_reduce").val(viewCode.reduce || "");
var lines = Math.max(viewCode.map.split("\n").length,
(viewCode.reduce ? viewCode.reduce.split("\n").length : 1));
$("#viewcode textarea").attr("rows", Math.min(15, Math.max(3, lines)));
page.updateViewEditor(viewCode.map, viewCode.reduce || "");
$("#viewcode button.revert, #viewcode button.save").attr("disabled", "disabled");
page.storedViewCode = viewCode;
if (callback) callback();
@@ -271,13 +267,24 @@ function CouchDatabasePage() {
}
}

this.updateViewEditor = function(mapFun, reduceFun) {
if (!mapFun) return;
$("#viewcode_map").val(mapFun);
$("#viewcode_reduce").val(reduceFun);
var lines = Math.max(
mapFun.split("\n").length,
reduceFun.split("\n").length
);
$("#viewcode textarea").attr("rows", Math.min(15, Math.max(3, lines)));
}

this.saveViewAs = function() {
if (viewName && /^_design/.test(viewName)) {
var viewNameParts = viewName.split("/");
var designDocId = viewNameParts[1];
var localViewName = viewNameParts[2];
} else {
var designDocId = "", localViewName = ""
var designDocId = "", localViewName = "";
}
$.showDialog("dialog/_save_view_as.html", {
load: function(elem) {
@@ -496,7 +503,7 @@ function CouchDatabasePage() {
$(document.body).removeClass("loading");
}

if (!viewName) {
if (!viewName || viewName == "_all_docs") {
$("#switch select")[0].selectedIndex = 0;
db.allDocs(options);
} else {

0 comments on commit 04ddce3

Please sign in to comment.