Ghost/core/client/router.js
Hannah Wolfe cc785cc981 Merge pull request #686 from matthojo/Sign-up-screen-UI
Improved Auth screen markup and validation checks
2013-09-12 06:25:27 -07:00

74 lines
2.5 KiB
JavaScript

/*global window, document, Ghost, Backbone, $, _ */
(function () {
"use strict";
Ghost.Router = Backbone.Router.extend({
routes: {
'' : 'blog',
'content/' : 'blog',
'settings/' : 'settings',
'settings(/:pane)' : 'settings',
'editor/' : 'editor',
'editor(/:id)' : 'editor',
'debug/' : 'debug',
'register/' : 'register',
'signup/' : 'signup',
'signin/' : 'login',
'forgotten/' : 'forgotten'
},
signup: function () {
Ghost.currentView = new Ghost.Views.Signup({ el: '.js-signup-box' });
},
login: function () {
Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-box' });
},
forgotten: function () {
Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-forgotten-box' });
},
blog: function () {
var posts = new Ghost.Collections.Posts();
posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'] } }).then(function () {
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
});
},
settings: function (pane) {
if (!pane) {
// Redirect to settings/general if no pane supplied
this.navigate('/settings/general', {
trigger: true,
replace: true
});
return;
}
// only update the currentView if we don't already have a Settings view
if (!Ghost.currentView || !(Ghost.currentView instanceof Ghost.Views.Settings)) {
Ghost.currentView = new Ghost.Views.Settings({ el: '#main', pane: pane });
}
},
editor: function (id) {
var post = new Ghost.Models.Post();
post.urlRoot = Ghost.settings.apiRoot + '/posts';
if (id) {
post.id = id;
post.fetch().then(function () {
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
});
} else {
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
}
},
debug: function () {
Ghost.currentView = new Ghost.Views.Debug({ el: "#main" });
}
});
}());