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
1a1a7a4b
Commit
1a1a7a4b
authored
Jan 28, 2018
by
Seve
Committed by
JC Brand
Feb 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event and logic to display spoiler messages
parent
808cc385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
2 deletions
+36
-2
src/converse-spoilers.js
src/converse-spoilers.js
+36
-2
No files found.
src/converse-spoilers.js
View file @
1a1a7a4b
...
@@ -54,6 +54,39 @@
...
@@ -54,6 +54,39 @@
}
}
function
toggleDisplaySpoilerMessage
(
event
)
{
let
button
=
event
.
target
;
let
isClosed
=
button
.
getAttribute
(
"
closed
"
);
let
content
=
button
.
nextElementSibling
;
let
hint
=
content
.
children
[
0
];
let
contentHidden
=
content
.
children
[
1
];
let
container
=
button
.
parentElement
;
if
(
isClosed
==
"
true
"
){
//Show spoiler's content
button
.
classList
.
remove
(
"
icon-eye
"
);
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
icon-eye-blocked
"
);
button
.
setAttribute
(
"
closed
"
,
"
false
"
);
button
.
textContent
=
_
(
'
Hide
'
);
container
.
style
.
backgroundColor
=
"
#D5FFD2
"
;
hint
.
classList
.
add
(
"
hidden
"
);
contentHidden
.
classList
.
remove
(
"
hidden
"
);
}
else
{
//Hide spoiler's content
button
.
classList
.
remove
(
"
icon-eye-blocked
"
);
button
.
classList
.
add
(
"
icon-eye
"
);
button
.
setAttribute
(
"
closed
"
,
"
true
"
);
button
.
textContent
=
_
(
'
Show
'
);
container
.
style
.
backgroundColor
=
"
Lavender
"
;
hint
.
classList
.
remove
(
"
hidden
"
);
contentHidden
.
classList
.
add
(
"
hidden
"
);
}
}
const
initSpoilers
=
function
()
{
const
initSpoilers
=
function
()
{
var
spoiler_button
=
document
.
createElement
(
'
li
'
);
var
spoiler_button
=
document
.
createElement
(
'
li
'
);
spoiler_button
.
classList
.
add
(
"
toggle-spoiler-edit
"
);
spoiler_button
.
classList
.
add
(
"
toggle-spoiler-edit
"
);
...
@@ -158,7 +191,8 @@
...
@@ -158,7 +191,8 @@
'
overrides
'
:
{
'
overrides
'
:
{
'
ChatBoxView
'
:
{
'
ChatBoxView
'
:
{
'
events
'
:
{
'
events
'
:
{
'
click .toggle-spoiler-edit
'
:
toggleEditSpoilerMessage
'
click .toggle-spoiler-edit
'
:
toggleEditSpoilerMessage
,
'
click .toggle-spoiler-display
'
:
toggleDisplaySpoilerMessage
},
},
'
createMessageStanza
'
:
function
()
{
'
createMessageStanza
'
:
function
()
{
...
@@ -212,7 +246,7 @@
...
@@ -212,7 +246,7 @@
content
.
appendChild
(
hint
);
content
.
appendChild
(
hint
);
content
.
appendChild
(
contentHidden
);
content
.
appendChild
(
contentHidden
);
//Spoiler's button
//Spoiler's button
button
.
classList
.
add
(
"
spoiler-button
"
);
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
icon-eye
"
);
button
.
classList
.
add
(
"
icon-eye
"
);
button
.
setAttribute
(
"
type
"
,
"
button
"
);
button
.
setAttribute
(
"
type
"
,
"
button
"
);
button
.
appendChild
(
document
.
createTextNode
(
_
(
'
Show
'
)));
button
.
appendChild
(
document
.
createTextNode
(
_
(
'
Show
'
)));
...
...
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