forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c82e597
commit e2b3c40
Showing
10 changed files
with
357 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*global window, document, Ghost, $, Backbone, _ */ | ||
(function () { | ||
"use strict"; | ||
|
||
// Set the url manually and id to '0' to force PUT requests | ||
Ghost.Models.Settings = Backbone.Model.extend({ | ||
url: '/api/v0.1/settings/', | ||
id: "0", | ||
defaults: { | ||
title: 'My Blog', | ||
description: '', | ||
email: '[email protected]' | ||
} | ||
}); | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/*global window, document, Ghost, Backbone, $, _, alert */ | ||
(function () { | ||
"use strict"; | ||
|
||
var Settings = {}; | ||
|
||
// Base view | ||
// ---------- | ||
Ghost.Views.Settings = Ghost.View.extend({ | ||
initialize: function (options) { | ||
this.addSubview(new Settings.Sidebar({ | ||
el: '.settings-sidebar', | ||
pane: options.pane, | ||
model: this.model | ||
})); | ||
|
||
this.$('input').iCheck({ | ||
checkboxClass: 'icheckbox_square-grey' | ||
}); | ||
} | ||
}); | ||
|
||
// Sidebar (tabs) | ||
// --------------- | ||
Settings.Sidebar = Ghost.View.extend({ | ||
initialize: function (options) { | ||
this.menu = this.$('.settings-menu'); | ||
this.showContent(options.pane || 'general'); | ||
}, | ||
|
||
events: { | ||
'click .settings-menu li' : 'switchPane' | ||
}, | ||
|
||
switchPane: function (e) { | ||
e.preventDefault(); | ||
var item = $(e.currentTarget), | ||
id = item.find('a').attr('href').substring(1); | ||
this.showContent(id); | ||
}, | ||
|
||
showContent: function (id) { | ||
Backbone.history.navigate('/settings/' + id); | ||
if (this.pane && '#' + id === this.pane.el) { | ||
return; | ||
} | ||
_.result(this.pane, 'destroy'); | ||
this.setActive(id); | ||
this.pane = new Settings[id]({ model: this.model }); | ||
this.pane.render(); | ||
}, | ||
|
||
setActive: function (id) { | ||
this.menu.find('li').removeClass('active'); | ||
this.menu.find('a[href=#' + id + ']').parent().addClass('active'); | ||
} | ||
}); | ||
|
||
// Content panes | ||
// -------------- | ||
Settings.Pane = Ghost.View.extend({ | ||
destroy: function () { | ||
this.$el.removeClass('active'); | ||
}, | ||
|
||
render: function () { | ||
this.$el.addClass('active'); | ||
} | ||
}); | ||
|
||
// TODO: render templates on the client | ||
// TODO: use some kind of data-binding for forms | ||
|
||
// ### General settings | ||
Settings.general = Settings.Pane.extend({ | ||
el: '#general', | ||
events: { | ||
'click .button-save': 'saveSettings' | ||
}, | ||
|
||
saveSettings: function () { | ||
this.model.save({ | ||
title: this.$('#blog-title').val(), | ||
email: this.$('#email-address').val() | ||
}, { | ||
success: function () { | ||
alert('Saved'); | ||
} | ||
}); | ||
}, | ||
|
||
render: function () { | ||
var settings = this.model.toJSON(); | ||
this.$('#blog-title').val(settings.title); | ||
this.$('#email-address').val(settings.email); | ||
Settings.Pane.prototype.render.call(this); | ||
} | ||
}); | ||
|
||
// ### Content settings | ||
Settings.content = Settings.Pane.extend({ | ||
el: '#content', | ||
events: { | ||
} | ||
}); | ||
|
||
// ### User settings | ||
Settings.users = Settings.Pane.extend({ | ||
el: '#users', | ||
events: { | ||
} | ||
}); | ||
|
||
// ### Appearance settings | ||
Settings.appearance = Settings.Pane.extend({ | ||
el: '#appearance', | ||
events: { | ||
} | ||
}); | ||
|
||
// ### Services settings | ||
Settings.services = Settings.Pane.extend({ | ||
el: '#services', | ||
events: { | ||
} | ||
}); | ||
|
||
// ### Plugins settings | ||
Settings.plugins = Settings.Pane.extend({ | ||
el: '#plugins', | ||
events: { | ||
} | ||
}); | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.