2013-07-11 23:02:18 +04:00
|
|
|
/*global window, document, Ghost, $, _, Backbone, JST */
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Ghost.Views.Debug = Ghost.View.extend({
|
|
|
|
events: {
|
2013-12-25 04:05:20 +04:00
|
|
|
"click .settings-menu a": "handleMenuClick",
|
|
|
|
"click .js-delete": "handleDeleteClick"
|
2013-07-11 23:02:18 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
handleMenuClick: function (ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
var $target = $(ev.currentTarget);
|
|
|
|
|
|
|
|
// Hide the current content
|
|
|
|
this.$(".settings-content").hide();
|
|
|
|
|
|
|
|
// Show the clicked content
|
|
|
|
this.$("#debug-" + $target.attr("class")).show();
|
|
|
|
|
|
|
|
return false;
|
2013-12-25 04:05:20 +04:00
|
|
|
},
|
|
|
|
handleDeleteClick: function (ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
this.addSubview(new Ghost.Views.Modal({
|
|
|
|
model: {
|
|
|
|
options: {
|
|
|
|
close: true,
|
|
|
|
confirm: {
|
|
|
|
accept: {
|
|
|
|
func: function () {
|
|
|
|
$.ajax({
|
|
|
|
url: Ghost.paths.apiRoot + '/db/',
|
|
|
|
type: 'DELETE',
|
|
|
|
headers: {
|
|
|
|
'X-CSRF-Token': $("meta[name='csrf-param']").attr('content')
|
|
|
|
},
|
|
|
|
success: function onSuccess(response) {
|
|
|
|
if (!response) {
|
|
|
|
throw new Error('No response received from server.');
|
|
|
|
}
|
|
|
|
if (!response.message) {
|
|
|
|
throw new Error(response.detail || 'Unknown error');
|
|
|
|
}
|
|
|
|
|
|
|
|
Ghost.notifications.addItem({
|
|
|
|
type: 'success',
|
|
|
|
message: response.message,
|
|
|
|
status: 'passive'
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
error: function onError(response) {
|
|
|
|
var responseText = JSON.parse(response.responseText),
|
|
|
|
message = responseText && responseText.error ? responseText.error : 'unknown';
|
|
|
|
Ghost.notifications.addItem({
|
|
|
|
type: 'error',
|
|
|
|
message: ['A problem was encountered while deleting content from your blog. Error: ', message].join(''),
|
|
|
|
status: 'passive'
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
text: "Yes"
|
|
|
|
},
|
|
|
|
reject: {
|
|
|
|
func: function () {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
text: "No"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: "action",
|
|
|
|
style: ["wide", "centered"],
|
|
|
|
animation: 'fade'
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
template: 'blank',
|
2013-12-27 17:50:47 +04:00
|
|
|
title: 'Would you really like to delete all content from your blog?',
|
|
|
|
text: '<p>This is permanent! No backups, no restores, no magic undo button. <br /> We warned you, ok?</p>'
|
2013-12-25 04:05:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
2013-07-11 23:02:18 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}());
|