From 4cd710ae4d2c813f41f8a8bb75595ec2202e7d6e Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Wed, 9 Dec 2009 23:06:13 +0000 Subject: A couple of Futon improvements: * JSON strings are now displayed as-is in the document view, without the escaping of new-lines and quotes. That dramatically improves readability of multi-line strings. * Same goes for editing of JSON string values. When a change to a field value is submitted, and the value is not valid JSON it is assumed to be a string. This improves editing of multi-line strings a lot. * Hitting tab in textareas no longer moves focus to the next form field, but simply inserts a tab character at the current caret position. * Fixed some font declarations. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@889013 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/futon.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'share/www/script/futon.js') diff --git a/share/www/script/futon.js b/share/www/script/futon.js index f6b1d9f6..31f04a90 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -159,6 +159,26 @@ }); } + $.fn.enableTabInsertion = function(chars) { + chars = chars || "\t"; + var width = chars.length; + return this.keydown(function(evt) { + if (evt.keyCode == 9) { + var v = this.value; + var start = this.selectionStart; + var scrollTop = this.scrollTop; + if (start !== undefined) { + this.value = v.slice(0, start) + chars + v.slice(start); + this.selectionStart = this.selectionEnd = start + width; + } else { + document.selection.createRange().text = chars; + this.caretPos += width; + } + return false; + } + }); + } + $(document) .ajaxStart(function() { $(this.body).addClass("loading"); }) .ajaxStop(function() { $(this.body).removeClass("loading"); }); -- cgit v1.2.3