Plato on Github
Report Home
ampersand/template/shared/client/app.js
Maintainability
73.98
Lines of code
45
Difficulty
9.20
Estimated Errors
0.29
Function weight
By Complexity
By SLOC
var app = require('ampersand-app'); var _ = require('lodash'); var config = require('clientconfig'); var Router = require('./router'); var MainView = require('./views/main'); var Me = require('./models/me'); var People = require('./models/persons'); var domReady = require('domready'); // attach our app to `window` so we can // easily access it from the console. window.app = app; // Extends our main app singleton app.extend({ me: new Me(), people: new People(), router: new Router(), // This is where it all starts init: function() { // Create and attach our main view this.mainView = new MainView({ model: this.me, el: document.body }); // this kicks off our backbutton tracking (browser history) // and will cause the first matching handler in the router // to fire. this.router.history.start({ pushState: true }); }, // This is a helper for navigating around the app. // this gets called by a global click handler that handles // all the <a> tags in the app. // it expects a url pathname for example: "/costello/settings" navigate: function(page) { var url = (page.charAt(0) === '/') ? page.slice(1) : page; this.router.history.navigate(url, { trigger: true }); } }); // run it on domReady domReady(_.bind(app.init, app));