From 6b791a4c10cd4e6b7594042967b87dbed0dcc9c4 Mon Sep 17 00:00:00 2001 From: Matthew Harrison-Jones Date: Mon, 5 Aug 2013 10:16:31 +0100 Subject: [PATCH] Moved delete post confirm alert to new modal format --- core/client/tpl/modals/blank.hbs | 1 + core/client/views/base.js | 2 + core/client/views/blog.js | 72 +++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 core/client/tpl/modals/blank.hbs diff --git a/core/client/tpl/modals/blank.hbs b/core/client/tpl/modals/blank.hbs new file mode 100644 index 0000000000..4667c87871 --- /dev/null +++ b/core/client/tpl/modals/blank.hbs @@ -0,0 +1 @@ +{{content.text}} \ No newline at end of file diff --git a/core/client/views/base.js b/core/client/views/base.js index 19dbaa9610..9120c6233d 100644 --- a/core/client/views/base.js +++ b/core/client/views/base.js @@ -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'); diff --git a/core/client/views/blog.js b/core/client/views/blog.js index 9c9d4d8789..1a2b956a8c 100644 --- a/core/client/views/blog.js +++ b/core/client/views/blog.js @@ -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) {