couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r946370 - /couchdb/trunk/share/www/script/futon.browse.js
Date Wed, 19 May 2010 20:18:00 GMT
Author: jan
Date: Wed May 19 20:17:59 2010
New Revision: 946370

URL: http://svn.apache.org/viewvc?rev=946370&view=rev
Log:
Use "expando links" for long attribute values in the Futon document view.

Patch by Mikeal Rogers. Closes COUCHDB-766.

Modified:
    couchdb/trunk/share/www/script/futon.browse.js

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=946370&r1=946369&r2=946370&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Wed May 19 20:17:59 2010
@@ -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);



Mime
View raw message