summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/www/database.html7
-rw-r--r--share/www/script/futon.browse.js13
-rw-r--r--share/www/script/futon.js6
3 files changed, 17 insertions, 9 deletions
diff --git a/share/www/database.html b/share/www/database.html
index 64785e14..b997f2cf 100644
--- a/share/www/database.html
+++ b/share/www/database.html
@@ -71,8 +71,13 @@ specific language governing permissions and limitations under the License.
// Restore preferences/state
$("#documents thead th.key").toggleClass("desc", $.futon.storage.get("desc"));
+ var reduce = $.futon.storage.get("reduce");
+ $("#reduce :checkbox")[0].checked = reduce;
$("#grouplevel select").val($.futon.storage.get("group_level"));
- $("#reduce :checkbox")[0].checked = $.futon.storage.get("reduce");
+ $("#grouplevel").toggleClass("disabled", !reduce).find("select").each(function() {
+ this.disabled = !reduce;
+ });
+
$("#perpage").val($.futon.storage.get("per_page"));
page.populateViewsMenu();
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index 9faf7669..733c9d08 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -101,8 +101,8 @@
$.futon.storage.declareWithPrefix(dbName + ".", {
desc: {},
language: {defaultValue: "javascript"},
- map_fun: {},
- reduce_fun: {},
+ map_fun: {defaultValue: ""},
+ reduce_fun: {defaultValue: ""},
reduce: {},
group_level: {defaultValue: 100},
per_page: {defaultValue: 10},
@@ -197,6 +197,7 @@
map: $("#viewcode_map").val(),
reduce: $("#viewcode_reduce").val()
};
+ $("#reduce, #grouplevel").toggle(!!viewCode.reduce);
page.isDirty = (viewCode.map != page.storedViewCode.map)
|| (viewCode.reduce != (page.storedViewCode.reduce || ""))
|| page.viewLanguage != page.storedViewLanguage;
@@ -205,7 +206,6 @@
} else {
buttons.attr("disabled", "disabled");
}
- $("#reduce, #grouplevel").toggle(!!viewCode.reduce);
}, 100);
}
$("#viewcode textarea").enableTabInsertion()
@@ -222,10 +222,11 @@
page.updateDocumentListing();
});
} else if (viewName == "_temp_view") {
+ $("#viewcode textarea").enableTabInsertion();
page.viewLanguage = $.futon.storage.get("language");
page.updateViewEditor(
- $.futon.storage.get("map", templates[page.viewLanguage]),
- $.futon.storage.get("reduce")
+ $.futon.storage.get("map_fun", templates[page.viewLanguage]),
+ $.futon.storage.get("reduce_fun")
);
} else {
$("#grouplevel, #reduce").hide();
@@ -671,8 +672,6 @@
} else {
options.reduce = false;
}
- } else {
- $.futon.storage.del("reduce");
}
$.futon.storage.set("language", page.viewLanguage);
db.query(mapFun, reduceFun, page.viewLanguage, options);
diff --git a/share/www/script/futon.js b/share/www/script/futon.js
index f5a81444..1f51bdee 100644
--- a/share/www/script/futon.js
+++ b/share/www/script/futon.js
@@ -168,7 +168,11 @@
this.set = function(name, value) {
lookup(name, function(decl) {
- handlers[decl.scope].set(decl.prefix + name, value);
+ if (value == decl.defaultValue) {
+ handlers[decl.scope].del(decl.prefix + name);
+ } else {
+ handlers[decl.scope].set(decl.prefix + name, value);
+ }
});
}