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 EEC63F5D4 for ; Tue, 9 Apr 2013 02:10:04 +0000 (UTC) Received: (qmail 80479 invoked by uid 500); 9 Apr 2013 02:10:04 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 80252 invoked by uid 500); 9 Apr 2013 02:10:04 -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 80199 invoked by uid 99); 9 Apr 2013 02:10:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Apr 2013 02:10:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5904C51D13; Tue, 9 Apr 2013 02:10:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chewbranca@apache.org To: commits@couchdb.apache.org Date: Tue, 09 Apr 2013 02:10:04 -0000 Message-Id: <8d5b5a32a8a34f29848ca576705787b4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/route-events to 88eab77 Updated Branches: refs/heads/route-events [created] 88eab7777 Working route objects Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/feda2cdc Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/feda2cdc Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/feda2cdc Branch: refs/heads/route-events Commit: feda2cdc9c51b0e2d3410c4a926643a6a19092c6 Parents: e65d7b7 Author: Russell Branca Authored: Mon Apr 8 22:08:07 2013 -0400 Committer: Russell Branca Committed: Mon Apr 8 22:08:07 2013 -0400 ---------------------------------------------------------------------- src/fauxton/app/api.js | 56 ++++++++++++++++++++++ src/fauxton/app/modules/databases/routes.js | 53 ++++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/feda2cdc/src/fauxton/app/api.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js index 52e8611..c44efa1 100644 --- a/src/fauxton/app/api.js +++ b/src/fauxton/app/api.js @@ -96,6 +96,62 @@ function(app, Fauxton) { } }); + FauxtonAPI.RouteObject = function(options) { + this._options = options; + + this._configure(options || {}); + this.initialize.apply(this, arguments); + this.addEvents(); + }; + + var routeObjectOptions = ["views", "routes", "events", "data", "crumbs", "layout", "apiUrl", "establish"]; + + _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, { + // Should these be default vals or empty funcs? + views: {}, + routes: {}, + events: {}, + data: {}, + crumbs: [], + layout: null, + apiUrl: null, + establish: null + }, { + route: function() {}, + initialize: function() {}, + renderWith: function(layout) { + }, + get: function(key) { + return _.isFunction(this[key]) ? this[key]() : this[key]; + }, + addEvents: function(events) { + events = events || this.get('events'); + _.each(events, function(method, event) { + if (!_.isFunction(method) && !_.isFunction(this[method])) { + throw new Error("Invalid method: "+method); + } + method = _.isFunction(method) ? method : this[method]; + + this.on(event, method); + }, this); + }, + _configure: function(options) { + /* + _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) { + this[key] = options[key]; + }, this); + */ + _.each(options, function(val, key) { this[key] = val; }, this); + }, + setView: function(selector, view) { + this.views[selector] = view; + return view; + }, + getViews: function() { + return this.views; + } + }); + app.fauxtonAPI = FauxtonAPI; return app.fauxtonAPI; }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/feda2cdc/src/fauxton/app/modules/databases/routes.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js index 2ba59d7..f6a6226 100644 --- a/src/fauxton/app/modules/databases/routes.js +++ b/src/fauxton/app/modules/databases/routes.js @@ -16,10 +16,59 @@ define([ "api", // Modules - "modules/databases/resources" + "modules/databases/resources", + // TODO:: fix the include flow modules so we don't have to require views here + "modules/databases/views" ], -function(app, FauxtonAPI, Databases) { +function(app, FauxtonAPI, Databases, Views) { + var allDbsRouteObject = Databases.AllDbsRouteObject = new FauxtonAPI.RouteObject({ + layout: "with_sidebar", + + crumbs: [ + {"name": "Databases", "link": "/_all_dbs"} + ], + + apiUrl: function() { + return this.databases.url(); + }, + + initialize: function() { + this.databases = new Databases.List(); + this.deferred = FauxtonAPI.Deferred(); + + this.setView("#dashboard-content", new Views.List({ + collection: this.databases + })); + this.setView("#sidebar-content", new Views.Sidebar({ + collection: this.databases + })); + }, + + establish: function() { + var databases = this.databases; + var deferred = this.deferred; + + databases.fetch().done(function(resp) { + $.when.apply(null, databases.map(function(database) { + return database.status.fetch(); + })).done(function(resp) { + deferred.resolve(); + }); + }); + + return [deferred]; + }, + + mrEvent: function() { + console.log("Triggering a most excellent event!!!!"); + }, + + events: { + "myrandom_event": "mrEvent" + } + }); + var allDbsCallback = function() { var data = { databases: new Databases.List()