summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-10-13 12:45:15 -0700
committerSteve Manuel <nilslice@gmail.com>2016-10-13 12:45:15 -0700
commit4dceec07d9f34018f70b15f795e4af27ff753dc3 (patch)
tree7ea9ebdc2a1d29df1fbbeaab3860c7839d10de98
parent6148ddb2473f00fb74b135e00127bbadd2062861 (diff)
adding logic to hide delete button and handling event
-rw-r--r--management/editor/editor.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/management/editor/editor.go b/management/editor/editor.go
index 85214f0..f8b1970 100644
--- a/management/editor/editor.go
+++ b/management/editor/editor.go
@@ -54,7 +54,13 @@ func Form(post Editable, fields ...Field) ([]byte, error) {
<script>
$(function() {
var form = $('form'),
- del = form.find('button.delete-post');
+ del = form.find('button.delete-post'),
+ id = form.find('input[name=id]');
+
+ // hide delete button if this is a new post, or a non-post editor page
+ if (id.val() === '-1' || form.attr('action') !== '/admin/edit') {
+ del.hide();
+ }
del.on('click', function(e) {
e.preventDefault();
@@ -62,7 +68,7 @@ func Form(post Editable, fields ...Field) ([]byte, error) {
action = action + '/delete';
form.attr('action', action);
- if (confirm("Ponzu: Please confirm:\n\nAre you sure you want to delete this post?\nThis cannot be undone.")) {
+ if (confirm("[Ponzu] Please confirm:\n\nAre you sure you want to delete this post?\nThis cannot be undone.")) {
form.submit();
}
});