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
7ee0b194
Commit
7ee0b194
authored
Feb 06, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code to chatview
parent
253c4d73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
45 deletions
+51
-45
src/converse-chatview.js
src/converse-chatview.js
+51
-0
src/converse-spoilers.js
src/converse-spoilers.js
+0
-45
No files found.
src/converse-chatview.js
View file @
7ee0b194
...
...
@@ -619,6 +619,53 @@
}
},
renderSpoilerMessage
(
msg
,
attrs
)
{
/* Render a "spoiler" message, as defined in XEP-0382
*
* Parameters:
* (Object) attrs: An object containing the message attributes.
*/
console
.
log
(
'
Spoiler in attrs
\n
'
);
const
button
=
document
.
createElement
(
"
button
"
);
const
container
=
document
.
createElement
(
"
div
"
);
const
content
=
document
.
createElement
(
"
div
"
);
const
hint
=
document
.
createElement
(
"
div
"
);
const
contentHidden
=
document
.
createElement
(
"
div
"
);
const
messageContent
=
msg
.
querySelector
(
"
.chat-msg-content
"
);
hint
.
appendChild
(
document
.
createTextNode
(
attrs
.
spoiler_hint
));
for
(
var
i
=
0
;
i
<
messageContent
.
childNodes
.
length
;
i
++
){
contentHidden
.
append
(
messageContent
.
childNodes
[
i
]);
}
contentHidden
.
classList
.
add
(
"
hidden
"
);
// contentHidden.addHyperlinks();
// contentHidden.addEmoticons(_converse.visible_toolbar_buttons.emoticons);
container
.
style
.
backgroundColor
=
"
Lavender
"
;
container
.
style
.
textAlign
=
"
center
"
;
//Spoiler's content
content
.
classList
.
add
(
"
spoiler-content
"
);
content
.
appendChild
(
hint
);
content
.
appendChild
(
contentHidden
);
//Spoiler's button
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
icon-eye
"
);
button
.
setAttribute
(
"
type
"
,
"
button
"
);
button
.
appendChild
(
document
.
createTextNode
(
__
(
'
Show
'
)));
button
.
style
.
width
=
"
100%
"
;
button
.
setAttribute
(
"
closed
"
,
"
true
"
);
container
.
appendChild
(
button
);
container
.
appendChild
(
content
);
messageContent
.
textContent
=
""
;
messageContent
.
append
(
document
.
createElement
(
"
br
"
));
messageContent
.
append
(
container
);
return
msg
;
},
renderMessage
(
attrs
)
{
/* Renders a chat message based on the passed in attributes.
*
...
...
@@ -666,6 +713,10 @@
_converse
,
emojione
,
u
.
addHyperlinks
(
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}}))
);
u
.
renderImageURLs
(
msg_content
).
then
(
this
.
scrollDown
.
bind
(
this
));
if
(
attrs
.
is_spoiler
)
{
return
this
.
renderSpoilerMessage
(
msg
,
attrs
)
}
return
msg
;
},
...
...
src/converse-spoilers.js
View file @
7ee0b194
...
...
@@ -75,51 +75,6 @@
{
__
}
=
_converse
,
msg
=
this
.
__super__
.
renderMessage
.
apply
(
this
,
arguments
);
// Spoiler logic
// The value of the "spoiler" attribute, corresponds to the spoiler's hint.
if
(
attrs
.
is_spoiler
)
{
console
.
log
(
'
Spoiler in attrs
\n
'
);
const
button
=
document
.
createElement
(
"
button
"
);
const
container
=
document
.
createElement
(
"
div
"
);
const
content
=
document
.
createElement
(
"
div
"
);
const
hint
=
document
.
createElement
(
"
div
"
);
const
contentHidden
=
document
.
createElement
(
"
div
"
);
const
messageContent
=
msg
.
querySelector
(
"
.chat-msg-content
"
);
hint
.
appendChild
(
document
.
createTextNode
(
attrs
.
spoiler_hint
));
for
(
var
i
=
0
;
i
<
messageContent
.
childNodes
.
length
;
i
++
){
contentHidden
.
append
(
messageContent
.
childNodes
[
i
]);
}
contentHidden
.
classList
.
add
(
"
hidden
"
);
// contentHidden.addHyperlinks();
// contentHidden.addEmoticons(_converse.visible_toolbar_buttons.emoticons);
container
.
style
.
backgroundColor
=
"
Lavender
"
;
container
.
style
.
textAlign
=
"
center
"
;
//Spoiler's content
content
.
classList
.
add
(
"
spoiler-content
"
);
content
.
appendChild
(
hint
);
content
.
appendChild
(
contentHidden
);
//Spoiler's button
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
icon-eye
"
);
button
.
setAttribute
(
"
type
"
,
"
button
"
);
button
.
appendChild
(
document
.
createTextNode
(
__
(
'
Show
'
)));
button
.
style
.
width
=
"
100%
"
;
button
.
setAttribute
(
"
closed
"
,
"
true
"
);
container
.
appendChild
(
button
);
container
.
appendChild
(
content
);
console
.
log
(
'
And this is the container:
\n
'
);
console
.
log
(
container
);
messageContent
.
textContent
=
""
;
messageContent
.
append
(
document
.
createElement
(
"
br
"
));
messageContent
.
append
(
container
);
}
return
msg
;
}
}
...
...
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