Merge pull request #336 from matthojo/Delete-modals

Moved delete post confirm alert to new modal format
This commit is contained in:
Hannah Wolfe 2013-08-05 03:49:16 -07:00
commit 11be64c544
3 changed files with 51 additions and 24 deletions

View File

@ -0,0 +1 @@
{{content.text}}

View File

@ -182,9 +182,11 @@
// Initiate functions for buttons here so models don't get tied up.
this.acceptModal = function () {
this.model.options.confirm.accept.func();
self.removeItem();
};
this.rejectModal = function () {
this.model.options.confirm.reject.func();
self.removeItem();
};
shortcut.remove("ESC");
$(document).off('click', '.modal-background');

View File

@ -141,30 +141,54 @@
deletePost: function (e) {
e.preventDefault();
if (window.confirm('Are you sure you want to delete this post?')) {
var self = this,
title = self.model.get('title');
self.model.destroy({
wait: true
}).then(function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'success',
message: 'Your post: ' + title + ' has been deleted',
status: 'passive'
}]
}));
}, function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'error',
message: 'Your post: ' + title + ' has not been deleted.',
status: 'passive'
}]
}));
});
}
var self = this,
title = self.model.get('title');
this.addSubview(new Ghost.Views.Modal({
model: {
options: {
close: false,
confirm: {
accept: {
func: function () {
self.model.destroy({
wait: true
}).then(function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'success',
message: 'Your post: ' + title + ' has been deleted',
status: 'passive'
}]
}));
}, function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'error',
message: 'Your post: ' + title + ' has not been deleted.',
status: 'passive'
}]
}));
});
},
text: "Yes"
},
reject: {
func: function () {
return true;
},
text: "No"
}
},
type: "action",
style: "wide",
animation: 'fadeIn'
},
content: {
template: 'blank',
title: 'Are you sure you want to delete this post?'
}
}
}));
},
editPost: function (e) {