Commit 4451a7c8 authored by Seve's avatar Seve Committed by JC Brand

Use events in a less obscure manner

parent affd08bd
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
moment = converse.env.moment; moment = converse.env.moment;
function isEditSpoilerMessage() { function isEditSpoilerMessage() {
return document.querySelector('.toggle-spoiler').getAttribute('active') === 'true'; return document.querySelector('.toggle-spoiler-edit').getAttribute('active') === 'true';
} }
function hasHint() { function hasHint() {
...@@ -102,9 +102,8 @@ ...@@ -102,9 +102,8 @@
*/ */
const initSpoilers = function () { const initSpoilers = function () {
var spoiler_button = document.createElement('li'); var spoiler_button = document.createElement('li');
spoiler_button.classList.add("toggle-spoiler"); spoiler_button.classList.add("toggle-spoiler-edit");
spoiler_button.setAttribute("active", "false"); spoiler_button.setAttribute("active", "false");
spoiler_button.onclick = toggleEditSpoilerMessage;
spoiler_button.innerHTML = '<a class="icon-eye" title="' + _('Click here to write a message as a spoiler') + '"></a>'; spoiler_button.innerHTML = '<a class="icon-eye" title="' + _('Click here to write a message as a spoiler') + '"></a>';
document.querySelector('.chat-toolbar').appendChild(spoiler_button); document.querySelector('.chat-toolbar').appendChild(spoiler_button);
}; };
...@@ -113,7 +112,7 @@ ...@@ -113,7 +112,7 @@
let form = document.querySelector('.sendXMPPMessage'); let form = document.querySelector('.sendXMPPMessage');
let textArea = document.querySelector('.chat-textarea'); let textArea = document.querySelector('.chat-textarea');
let hintTextArea = null; let hintTextArea = null;
let spoiler_button = document.querySelector('.toggle-spoiler'); let spoiler_button = document.querySelector('.toggle-spoiler-edit');
if (!isEditSpoilerMessage()) { if (!isEditSpoilerMessage()) {
textArea.style['background-color'] = '#D5FFD2'; textArea.style['background-color'] = '#D5FFD2';
...@@ -156,6 +155,10 @@ ...@@ -156,6 +155,10 @@
*/ */
'overrides': { 'overrides': {
'ChatBoxView': { 'ChatBoxView': {
'events': {
'click .toggle-spoiler-edit': toggleEditSpoilerMessage
},
'createMessageStanza': function () { 'createMessageStanza': function () {
let messageStanza = this.__super__.createMessageStanza.apply(this, arguments); let messageStanza = this.__super__.createMessageStanza.apply(this, arguments);
if (isEditSpoilerMessage()) { if (isEditSpoilerMessage()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment