summaryrefslogtreecommitdiff
path: root/share/www/script/futon.browse.js
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2010-05-19 20:17:59 +0000
committerJan Lehnardt <jan@apache.org>2010-05-19 20:17:59 +0000
commit1328c4ca455854752071963ef4260cf768923389 (patch)
treeb5d178a5f54612a8ef60602226b82a3800d36863 /share/www/script/futon.browse.js
parent3ea5d80b7b98b722a426c8aaccaffe547ee11980 (diff)
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
Diffstat (limited to 'share/www/script/futon.browse.js')
-rw-r--r--share/www/script/futon.browse.js35
1 files changed, 34 insertions, 1 deletions
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 = $('<a href="#expand">...</a>');
+ var m = $('<a href="#min">X</a>');
+ 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 = $('<a href="#expand">...</a>');
+ 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);