couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r954886 - /couchdb/branches/0.11.x/share/www/script/futon.browse.js
Date Tue, 15 Jun 2010 13:55:41 GMT
Author: jan
Date: Tue Jun 15 13:55:40 2010
New Revision: 954886

URL: http://svn.apache.org/viewvc?rev=954886&view=rev
Log:
Merge r946370 from trunk:

Use "expando links" for long attribute values in the Futon document view.

Patch by Mikeal Rogers. Closes COUCHDB-766.

Modified:
    couchdb/branches/0.11.x/share/www/script/futon.browse.js

Modified: couchdb/branches/0.11.x/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/futon.browse.js?rev=954886&r1=954885&r2=954886&view=diff
==============================================================================
--- couchdb/branches/0.11.x/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/branches/0.11.x/share/www/script/futon.browse.js [utf-8] Tue Jun 15 13:55:40 2010
@@ -1170,7 +1170,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