From f2a91f36366d270b59d208712e59cf32533006be Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Tue, 21 Jul 2009 21:06:00 +0000 Subject: Make the view-selection and jump-to-document widgets at the top of the Futon database page a bit more compact. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@796535 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/futon.browse.js | 8 ++++---- share/www/script/futon.js | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'share/www/script') diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js index 9bf01752..6aeb14f3 100644 --- a/share/www/script/futon.browse.js +++ b/share/www/script/futon.browse.js @@ -466,10 +466,10 @@ } } - this.jumpToDocument = function(e) { - if (e.which == 13) { - var docid = $('#jumpto input').val(); - location.href = 'document.html?' + encodeURIComponent(db.name) + '/' + encodeDocId(docid); + this.jumpToDocument = function(docId) { + if (docId != "") { + location.href = 'document.html?' + encodeURIComponent(db.name) + + "/" + encodeDocId(docId); } } diff --git a/share/www/script/futon.js b/share/www/script/futon.js index 77bd8cc8..bdfbe93a 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -107,6 +107,33 @@ navigation: new Navigation() }); + $.fn.addPlaceholder = function(text) { + return this.each(function() { + var input = $(this); + if ($.browser.safari) { + input.attr("placeholder", text); + return; + } + input.blur(function() { + if ($.trim(input.val()) == "") { + input.addClass("placeholder").val(text); + } else { + input.removeClass("placeholder"); + } + }).triggerHandler("blur") + input.focus(function() { + if (input.is(".placeholder")) { + input.val("").removeClass("placeholder"); + } + }); + $(this.form).submit(function() { + if (input.is(".placeholder")) { + input.val(""); + } + }); + }); + } + $(document) .ajaxStart(function() { $(this.body).addClass("loading"); }) .ajaxStop(function() { $(this.body).removeClass("loading"); }); -- cgit v1.2.3