Merge pull request #605 from jgable/settingsBackButton

Fix settings back button functionality
This commit is contained in:
Hannah Wolfe 2013-09-03 04:20:25 -07:00
commit d38faddca1
2 changed files with 28 additions and 3 deletions

View File

@ -38,6 +38,15 @@
},
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 });

View File

@ -9,11 +9,26 @@
Ghost.Views.Settings = Ghost.View.extend({
initialize: function (options) {
$(".settings-content").removeClass('active');
this.addSubview(new Settings.Sidebar({
this.sidebar = new Settings.Sidebar({
el: '.settings-sidebar',
pane: options.pane,
model: this.model
}));
});
this.addSubview(this.sidebar);
this.listenTo(Ghost.router, "route:settings", this.changePane);
},
changePane: function (pane) {
if (!pane) {
// Can happen when trying to load /settings with no pane specified
// let the router navigate itself to /settings/general
return;
}
this.sidebar.showContent(pane);
}
});
@ -23,7 +38,7 @@
initialize: function (options) {
this.render();
this.menu = this.$('.settings-menu');
this.showContent(options.pane || 'general');
this.showContent(options.pane);
},
models: {},
@ -36,6 +51,7 @@
e.preventDefault();
var item = $(e.currentTarget),
id = item.find('a').attr('href').substring(1);
this.showContent(id);
},