Commit 86661677a7623472280bc05e563bb733054a0f01
edits should cancel correctly
Ev Bogue committed on 5/26/2018, 1:13:21 AMParent: c0fd0e300786fa560756710190772845cd949008
Files changed
compose.js | changed |
compose.js | ||
---|---|---|
@@ -40,38 +40,36 @@ | ||
40 | 40 | module.exports = function (opts, buttons) { |
41 | 41 | var files = [] |
42 | 42 | var filesById = {} |
43 | 43 | |
44 | + console.log(opts) | |
45 | + | |
44 | 46 | var composer = h('div.composer') |
45 | 47 | var container = h('div.container') |
46 | 48 | |
47 | 49 | if (opts.messageText) |
48 | 50 | var textarea = h('textarea.compose', opts.messageText) |
49 | 51 | else |
50 | 52 | var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message'}) |
51 | 53 | |
52 | - if (window.location.hash.substring(1) != 'compose') | |
53 | - var cancelBtn = h('button.btn', 'Cancel', { | |
54 | - onclick: function () { | |
55 | - var cancel | |
56 | - if (opts.type == 'updated') { | |
57 | - cancel = document.getElementById(opts.updated.substring(0,10)) | |
58 | - var oldMessage = h('div.message__body', tools.markdown(opts.messageText)) | |
59 | - cancel.parentNode.replaceChild(oldMessage, cancel) | |
60 | - oldMessage.parentNode.appendChild(buttons) | |
61 | - } else { | |
62 | - if (document.getElementById(opts.branch.substring(0,10))) | |
63 | - cancel = document.getElementById(opts.branch.substring(0,10)) | |
64 | - else | |
65 | - cancel = document.getElementById('composer') | |
66 | - cancel.parentNode.removeChild(cancel) | |
67 | - } | |
54 | + var cancelBtn = h('button.btn', 'Cancel', { | |
55 | + onclick: function () { | |
56 | + var cancel | |
57 | + if (opts.updated) { | |
58 | + cancel = document.getElementById(opts.updated.substring(0,10)) | |
59 | + var oldMessage = h('div.message__body', tools.markdown(opts.messageText)) | |
60 | + cancel.parentNode.replaceChild(oldMessage, cancel) | |
61 | + oldMessage.parentNode.appendChild(buttons) | |
62 | + } else if (opts.branch) { | |
63 | + cancel = document.getElementById(opts.branch.substring(0,10)) | |
64 | + cancel.parentNode.removeChild(cancel) | |
65 | + } else { | |
66 | + cancel = document.getElementById('composer') | |
67 | + cancel.parentNode.removeChild(cancel) | |
68 | 68 | } |
69 | + } | |
69 | 70 | |
70 | - }) | |
71 | - | |
72 | - else | |
73 | - var cancel = h('span', '') | |
71 | + }) | |
74 | 72 | |
75 | 73 | var initialButtons = h('span', |
76 | 74 | h('button.btn', 'Preview', { |
77 | 75 | onclick: function () { |
Built with git-ssb-web