Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
4451a7c8
Commit
4451a7c8
authored
Dec 18, 2017
by
Seve
Committed by
JC Brand
Feb 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use events in a less obscure manner
parent
affd08bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/converse-spoilers.js
src/converse-spoilers.js
+13
-10
No files found.
src/converse-spoilers.js
View file @
4451a7c8
...
...
@@ -14,7 +14,7 @@
moment
=
converse
.
env
.
moment
;
function
isEditSpoilerMessage
()
{
return
document
.
querySelector
(
'
.toggle-spoiler
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
return
document
.
querySelector
(
'
.toggle-spoiler
-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
}
function
hasHint
()
{
...
...
@@ -24,7 +24,7 @@
function
getHint
()
{
return
document
.
querySelector
(
'
.chat-textarea-hint
'
).
value
;
}
// The following line registers your plugin.
converse
.
plugins
.
add
(
"
converse-spoilers
"
,
{
...
...
@@ -102,19 +102,18 @@
*/
const
initSpoilers
=
function
()
{
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
.
onclick
=
toggleEditSpoilerMessage
;
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
);
};
function
toggleEditSpoilerMessage
()
{
let
form
=
document
.
querySelector
(
'
.sendXMPPMessage
'
);
let
textArea
=
document
.
querySelector
(
'
.chat-textarea
'
);
let
hintTextArea
=
null
;
let
spoiler_button
=
document
.
querySelector
(
'
.toggle-spoiler
'
);
let
spoiler_button
=
document
.
querySelector
(
'
.toggle-spoiler
-edit
'
);
if
(
!
isEditSpoilerMessage
())
{
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
textArea
.
setAttribute
(
'
placeholder
'
,
_
(
'
Write your spoiler
\'
s content here
'
));
...
...
@@ -132,12 +131,12 @@
hintTextArea
=
document
.
querySelector
(
'
.chat-textarea-hint
'
);
if
(
hintTextArea
)
{
hintTextArea
.
remove
();
}
}
}
function
createHintTextArea
(){
let
hintTextArea
=
document
.
createElement
(
'
input
'
);
hintTextArea
.
setAttribute
(
'
type
'
,
'
text
'
);
...
...
@@ -156,6 +155,10 @@
*/
'
overrides
'
:
{
'
ChatBoxView
'
:
{
'
events
'
:
{
'
click .toggle-spoiler-edit
'
:
toggleEditSpoilerMessage
},
'
createMessageStanza
'
:
function
()
{
let
messageStanza
=
this
.
__super__
.
createMessageStanza
.
apply
(
this
,
arguments
);
if
(
isEditSpoilerMessage
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment