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
fa06b528
Commit
fa06b528
authored
Feb 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also show spoiler for sent messages.
parent
d6da643a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
18 deletions
+33
-18
src/converse-chatview.js
src/converse-chatview.js
+15
-9
src/converse-spoilers.js
src/converse-spoilers.js
+17
-8
src/templates/spoiler_button.html
src/templates/spoiler_button.html
+1
-1
No files found.
src/converse-chatview.js
View file @
fa06b528
...
...
@@ -753,18 +753,24 @@
return
;
}
}
let
fullname
=
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
fullname
=
_
.
isEmpty
(
fullname
)?
_converse
.
bare_jid
:
fullname
;
const
message
=
this
.
model
.
messages
.
create
({
fullname
,
sender
:
'
me
'
,
time
:
moment
().
format
(),
message
:
emojione
.
shortnameToUnicode
(
text
)
});
const
attrs
=
this
.
getOutgoingMessageAttributes
(
text
)
const
message
=
this
.
model
.
messages
.
create
(
attrs
);
this
.
sendMessage
(
message
);
},
getOutgoingMessageAttributes
(
text
)
{
/* Overridable method which returns the attributes to be
* passed to Backbone.Message's constructor.
*/
const
fullname
=
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
return
{
'
fullname
'
:
_
.
isEmpty
(
fullname
)
?
_converse
.
bare_jid
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
moment
().
format
(),
'
message
'
:
emojione
.
shortnameToUnicode
(
text
)
}
},
sendChatState
()
{
/* Sends a message with the status of the user in this chat session
* as taken from the 'chat_state' attribute of the chat box.
...
...
src/converse-spoilers.js
View file @
fa06b528
...
...
@@ -61,11 +61,20 @@
return
result
;
},
isEditSpoilerMessage
()
{
return
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
getOutgoingMessageAttributes
(
text
)
{
debugger
;
const
{
__
}
=
this
.
__super__
.
_converse
,
attrs
=
this
.
__super__
.
getOutgoingMessageAttributes
.
apply
(
this
,
arguments
);
if
(
this
.
model
.
get
(
'
sending_spoiler
'
))
{
const
spoiler
=
this
.
el
.
querySelector
(
'
.chat-textarea-hint
'
)
attrs
.
is_spoiler
=
true
;
attrs
.
spoiler_hint
=
spoiler
.
textContent
.
length
>
0
?
spoiler
.
textContent
:
__
(
'
Spoiler
'
);
}
return
attrs
;
},
'
toggleSpoilerMessage
'
:
function
(
event
)
{
toggleSpoilerMessage
(
event
)
{
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
...
...
@@ -109,7 +118,7 @@
return
hintTextArea
;
},
'
toggleEditSpoilerMessage
'
:
function
()
{
toggleEditSpoilerMessage
()
{
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
...
...
@@ -117,10 +126,10 @@
const
textArea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
spoiler_button
=
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
);
if
(
this
.
isEditSpoilerMessage
(
))
{
if
(
this
.
model
.
get
(
'
sending_spoiler
'
))
{
textArea
.
style
[
'
background-color
'
]
=
''
;
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Personal message
'
));
spoiler_button
.
setAttribute
(
"
active
"
,
"
false
"
);
this
.
model
.
set
(
'
sending_spoiler
'
,
false
);
spoiler_button
.
innerHTML
=
'
<a class="icon-eye" title="
'
+
__
(
'
Click here to write a message as a spoiler
'
)
+
'
"></a>
'
;
// better get the element <a></a> and change the class?
const
hintTextArea
=
document
.
querySelector
(
'
.chat-textarea-hint
'
);
if
(
hintTextArea
)
{
...
...
@@ -129,7 +138,7 @@
}
else
{
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Write your spoiler
\'
s content here
'
));
spoiler_button
.
setAttribute
(
"
active
"
,
"
true
"
);
this
.
model
.
set
(
'
sending_spoiler
'
,
true
);
// TODO template
spoiler_button
.
innerHTML
=
'
<a class="icon-eye-blocked" title="
'
+
__
(
'
Cancel writing spoiler message
'
)
+
'
"></a>
'
;
// better get the element <a></a> and change the class?
...
...
@@ -139,7 +148,7 @@
},
addSpoilerElement
(
stanza
)
{
if
(
this
.
isEditSpoilerMessage
(
))
{
if
(
this
.
model
.
get
(
'
sending_spoiler
'
))
{
const
has_hint
=
this
.
el
.
querySelector
(
'
.chat-textarea-hint
'
).
value
.
length
>
0
;
if
(
has_hint
)
{
const
hint
=
document
.
querySelector
(
'
.chat-textarea-hint
'
).
value
;
...
...
src/templates/spoiler_button.html
View file @
fa06b528
<li
class=
"toggle-spoiler-edit"
data-active=
"false"
>
<li
class=
"toggle-spoiler-edit"
>
<a
class=
"icon-eye"
title=
"{{ o.title }}"
></a>
</li>
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