couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r735071 - in /couchdb/trunk/share/www/script: futon.browse.js jquery.suggest.js
Date Fri, 16 Jan 2009 18:01:34 GMT
Author: cmlenz
Date: Fri Jan 16 10:01:33 2009
New Revision: 735071

URL: http://svn.apache.org/viewvc?rev=735071&view=rev
Log:
Fix for autocompletion in "Save as" dialog in Futon to work with the changed `_all_docs` collation.

Modified:
    couchdb/trunk/share/www/script/futon.browse.js
    couchdb/trunk/share/www/script/jquery.suggest.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=735071&r1=735070&r2=735071&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Fri Jan 16 10:01:33 2009
@@ -331,12 +331,14 @@
           load: function(elem) {
             $("#input_docid", elem).val(designDocId).suggest(function(text, callback) {
               db.allDocs({
-                limit: 10, startkey: "_design/" + text,
-                endkey: "_design/" + text + "ZZZZ",
+                limit: 10, startkey: "_design/" + text, endkey: "_design0",
                 success: function(docs) {
                   var matches = [];
                   for (var i = 0; i < docs.rows.length; i++) {
-                    matches[i] = docs.rows[i].id.substr(8);
+                    var docName = docs.rows[i].id.substr(8);
+                    if (docName.substr(0, text.length) == text) {
+                      matches[i] = docName;
+                    }
                   }
                   callback(matches);
                 }
@@ -349,10 +351,9 @@
                   var matches = [];
                   if (!doc.views) return;
                   for (var viewName in doc.views) {
-                    if (!doc.views.hasOwnProperty(viewName) || !viewName.match("^" + text))
{
-                      continue;
+                    if (viewName.substr(0, text.length) == text) {
+                      matches.push(viewName);
                     }
-                    matches.push(viewName);
                   }
                   callback(matches);
                 }

Modified: couchdb/trunk/share/www/script/jquery.suggest.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.suggest.js?rev=735071&r1=735070&r2=735071&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.suggest.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.suggest.js [utf-8] Fri Jan 16 10:01:33 2009
@@ -38,7 +38,6 @@
         if ($.inArray(e.keyCode, [38, 40]) != -1 ||
             (dropdown.is(":visible") && (e.keyCode == 27 ||
              ($.inArray(e.keyCode, [9, 13]) != -1 && getSelection())))) {
-          e.preventDefault(); e.stopPropagation();
           switch(e.keyCode) {
             case 38: // up
               moveUp();
@@ -49,11 +48,13 @@
             case 9:  // tab
             case 13: // return
               commit();
+              if (e.keyCode == 9) return true;
               break;
             case 27: // escape
               dropdown.hide();
               break;
           }
+          e.preventDefault(); e.stopPropagation();
           return false;
         } else {
           timer = setTimeout(function() { suggest() }, options.delay);
@@ -120,11 +121,12 @@
   }
 
   $.fn.suggest = function(callback, options) {
-    options = options || {};
-    options.callback = callback;
-    options.delay = options.delay || 100;
-    options.dropdownClass = options.dropdownClass || "suggest-dropdown";
-    options.minChars = options.minChars || 1;
+    options = $.extend({
+      callback: callback,
+      delay: 100,
+      dropdownClass: "suggest-dropdown",
+      minChars: 1
+    }, options || {});
     return this.each(function() {
       suggest(this, options);
     });



Mime
View raw message