Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F16F10980 for ; Mon, 16 Dec 2013 20:03:27 +0000 (UTC) Received: (qmail 58624 invoked by uid 500); 16 Dec 2013 20:03:23 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 58247 invoked by uid 500); 16 Dec 2013 20:03:22 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 57550 invoked by uid 99); 16 Dec 2013 20:03:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Dec 2013 20:03:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1036E911AE7; Mon, 16 Dec 2013 20:03:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kxepal@apache.org To: commits@couchdb.apache.org Date: Mon, 16 Dec 2013 20:03:37 -0000 Message-Id: <28127774d01441689a8f622265272bc3@git.apache.org> In-Reply-To: <60afa012f3b1403090952d8d55b12b33@git.apache.org> References: <60afa012f3b1403090952d8d55b12b33@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [17/50] git commit: updated refs/heads/1744-single-config-file to 1c344a9 Fauxton: Fix search button Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/844ddfa3 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/844ddfa3 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/844ddfa3 Branch: refs/heads/1744-single-config-file Commit: 844ddfa3c4ae1695327de17f9816b28d19fdceb7 Parents: 9c942b5 Author: Garren Smith Authored: Wed Dec 4 10:33:57 2013 +0200 Committer: Garren Smith Committed: Wed Dec 4 16:31:26 2013 +0200 ---------------------------------------------------------------------- src/fauxton/Gruntfile.js | 5 +++-- src/fauxton/app/modules/databases/views.js | 20 +++++++++++++++----- src/fauxton/app/modules/fauxton/components.js | 12 +++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/src/fauxton/Gruntfile.js ---------------------------------------------------------------------- diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js index 42e5e17..6a8a73a 100644 --- a/src/fauxton/Gruntfile.js +++ b/src/fauxton/Gruntfile.js @@ -142,12 +142,13 @@ module.exports = function(grunt) { // The jshint option for scripturl is set to lax, because the anchor // override inside main.js needs to test for them so as to not accidentally - // route. + // route. Settings expr true so we can do `migtBeNullObject && mightBeNullObject.coolFunction()` jshint: { all: ['app/**/*.js', 'Gruntfile.js', "test/core/*.js"], options: { scripturl: true, - evil: true + evil: true, + expr: true } }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/src/fauxton/app/modules/databases/views.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js index 0f67d36..9a197a9 100644 --- a/src/fauxton/app/modules/databases/views.js +++ b/src/fauxton/app/modules/databases/views.js @@ -38,7 +38,8 @@ function(app, Components, FauxtonAPI) { template: "templates/databases/list", events: { "click button.all": "selectAll", - "submit form.database-search": "switchDatabase" + "submit form.database-search": "switchDatabase", + "click label.fonticon-search": "switchDatabase" }, initialize: function(options) { @@ -52,10 +53,15 @@ function(app, Components, FauxtonAPI) { }; }, - switchDatabase: function(event) { - event.preventDefault(); + switchDatabase: function(event, selectedName) { + event && event.preventDefault(); + var dbname = this.$el.find("input.search-query").val(); + if (selectedName) { + dbname = selectedName; + } + if (dbname) { // TODO: switch to using a model, or Databases.databaseUrl() // Neither of which are in scope right now @@ -77,7 +83,6 @@ function(app, Components, FauxtonAPI) { collection: this.collection })); - _.each(this.paginated(), function(database) { this.insertView("table.databases tbody", new Views.Item({ model: database @@ -99,9 +104,14 @@ function(app, Components, FauxtonAPI) { }, afterRender: function() { + var that = this; this.dbSearchTypeahead = new Components.DbSearchTypeahead({ dbLimit: this.dbLimit, - el: "input.search-query" + el: "input.search-query", + onUpdate: function (item) { + console.log('boom', item); + that.switchDatabase(null, item); + } }); this.dbSearchTypeahead.render(); http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/src/fauxton/app/modules/fauxton/components.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/fauxton/components.js b/src/fauxton/app/modules/fauxton/components.js index 0443573..bcc9226 100644 --- a/src/fauxton/app/modules/fauxton/components.js +++ b/src/fauxton/app/modules/fauxton/components.js @@ -116,8 +116,17 @@ function(app, FauxtonAPI, ace) { }, afterRender: function () { + var onUpdate = this.onUpdate; + this.$el.typeahead({ - source: this.source + source: this.source, + updater: function (item) { + if (onUpdate) { + onUpdate(item); + } + + return item; + } }); } @@ -127,6 +136,7 @@ function(app, FauxtonAPI, ace) { Components.DbSearchTypeahead = Components.Typeahead.extend({ initialize: function (options) { this.dbLimit = options.dbLimit || 30; + this.onUpdate = options.onUpdate; _.bindAll(this); }, source: function(query, process) {