diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-03-09 10:08:54 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-05-15 10:20:39 +0200 |
commit | 545ef1fb4c9395999693edf8eb02f0eb431fefeb (patch) | |
tree | 90a99ded2d2f14696489c2326870022ffbaacf92 | |
parent | 73db8179323c01bdd40eda2d587d52588f30a60f (diff) | |
download | couchdb-545ef1fb4c9395999693edf8eb02f0eb431fefeb.tar.gz |
initial addon created
-rw-r--r-- | src/fauxton/app/addons/user/base.js | 26 | ||||
-rw-r--r-- | src/fauxton/app/addons/user/resources.js | 38 | ||||
-rw-r--r-- | src/fauxton/app/addons/user/routes.js | 9 |
3 files changed, 73 insertions, 0 deletions
diff --git a/src/fauxton/app/addons/user/base.js b/src/fauxton/app/addons/user/base.js new file mode 100644 index 000000000..fd9d9c65f --- /dev/null +++ b/src/fauxton/app/addons/user/base.js @@ -0,0 +1,26 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +define([ + "app", + "api", + "addons/user/resources" +], + +function(app, FauxtonAPI, User) { + + User.initialize = function() { + FauxtonAPI.addHeaderLink({title: "User", href: "#user"}); + }; + + return User; +}); diff --git a/src/fauxton/app/addons/user/resources.js b/src/fauxton/app/addons/user/resources.js new file mode 100644 index 000000000..14101647a --- /dev/null +++ b/src/fauxton/app/addons/user/resources.js @@ -0,0 +1,38 @@ +define([ + "app", + "api" +], + +function (app, FauxtonAPI) { + var User = new FauxtonAPI.addon(); + + User.Session = Backbone.Model.extend({ + url: '/_session', + }); + + User.Info = FauxtonAPI.View.extend({ + + initialize:function (options) { + this.model.on('change', this.update_session, this); + }, + + update_session: function () { + console.log('update session'); + console.log(this.model); + } + }); + + var session = new User.Session(); + + User.Layout = Backbone.Layout.extend({ + views: { + 'a[href="#user"]': new User.Info({model: session}) + } + }); + + var layout = new User.Layout(); + + layout.render(); + session.fetch(); + return User; +}); diff --git a/src/fauxton/app/addons/user/routes.js b/src/fauxton/app/addons/user/routes.js new file mode 100644 index 000000000..010ab2477 --- /dev/null +++ b/src/fauxton/app/addons/user/routes.js @@ -0,0 +1,9 @@ +define([ + "app", + "api", + "addons/user/resources" +], + +function(app, FauxtonAPI, User) { + return User; +}); |