From 1328c4ca455854752071963ef4260cf768923389 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Wed, 19 May 2010 20:17:59 +0000 Subject: Use "expando links" for long attribute values in the Futon document view. Patch by Mikeal Rogers. Closes COUCHDB-766. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@946370 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/futon.browse.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js index 7bac338a..788d318c 100644 --- a/share/www/script/futon.browse.js +++ b/share/www/script/futon.browse.js @@ -1171,7 +1171,40 @@ html: true, escapeStrings: false }); - return $(html); + var n = $(html); + if (n.text().length > 140) { + // This code reduces a long string in to a summarized string with a link to expand it. + // Someone, somewhere, is doing something nasty with the event after it leaves these handlers. + // At this time I can't track down the offender, it might actually be a jQuery propogation issue. + var fulltext = n.text(); + var mintext = n.text().slice(0, 140); + var e = $('...'); + var m = $('X'); + var expand = function (evt) { + n.empty(); + n.text(fulltext); + n.append(m); + evt.stopPropagation(); + evt.stopImmediatePropagation(); + evt.preventDefault(); + } + var minimize = function (evt) { + n.empty(); + n.text(mintext); + // For some reason the old element's handler won't fire after removed and added again. + e = $('...'); + e.click(expand); + n.append(e); + evt.stopPropagation(); + evt.stopImmediatePropagation(); + evt.preventDefault(); + } + e.click(expand); + n.click(minimize); + n.text(mintext); + n.append(e) + } + return n; } } var elem = render(value); -- cgit v1.2.3