(function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; if (ELA.Models == null) { ELA.Models = {}; } ELA.Models.App = (function(superClass) { extend(App, superClass); function App() { return App.__super__.constructor.apply(this, arguments); } App.prototype.helpText = 'about'; App.prototype.defaults = { path: null, params: null, showAbout: false }; App.prototype.initialize = function() { this.on('change:path', this.handlePath); return this.on('change:params', this.handleParams); }; App.prototype.currentAppModel = function() { return this.get('currentAppModel'); }; App.prototype.currentApp = function() { var ref; return (ref = this.currentAppModel()) != null ? ref.currentApp() : void 0; }; App.prototype.currentNamespace = function() { var klass, path; path = this.get('path'); if (path != null) { klass = path[0].toCapitalCamel(); return ELA[klass]; } }; App.prototype.handlePath = function(model, path) { var AppClass, ref, ref1; if (path != null) { if (path[0] === 'about') { return this.set({ showAbout: true }); } else if (path[0] !== ((ref = this.currentAppModel()) != null ? ref.name : void 0)) { AppClass = this.currentNamespace().Models.App; return this.set({ showAbout: false, currentAppModel: new AppClass({ path: path.slice(1) }) }); } else { if ((ref1 = this.currentAppModel()) != null) { ref1.set({ path: path.slice(1) }); } return this.set({ showAbout: false }); } } else { return this.set({ currentAppModel: null, showAbout: false }); } }; App.prototype.handleParams = function(model, params) { if (params != null) { return this.currentApp().deserialize(params); } }; App.prototype.url = function() { var json, url; url = location.origin; if (json = this.toJSON()) { url += '/#app/' + this.get('path').join('/') + '?' + encodeURI(json); } return url; }; App.prototype.toJSON = function() { var currentApp; if (currentApp = this.currentApp()) { return JSON.stringify(currentApp.serialize()); } }; return App; })(Backbone.Model); }).call(this);