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
7870fc53
Commit
7870fc53
authored
Feb 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor adding of spoiler stanza element into separate method
parent
293ca2c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
src/converse-spoilers.js
src/converse-spoilers.js
+29
-29
No files found.
src/converse-spoilers.js
View file @
7870fc53
...
@@ -6,20 +6,10 @@
...
@@ -6,20 +6,10 @@
],
factory
);
],
factory
);
}(
this
,
function
(
converse
,
tpl_spoiler_button
)
{
}(
this
,
function
(
converse
,
tpl_spoiler_button
)
{
const
{
_
}
=
converse
.
env
;
const
{
_
,
Strophe
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
function
isEditSpoilerMessage
()
{
Strophe
.
addNamespace
(
'
SPOILER
'
,
'
urn:xmpp:spoiler:0
'
);
return
document
.
querySelector
(
'
.toggle-spoiler-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
}
function
hasHint
()
{
return
document
.
querySelector
(
'
.chat-textarea-hint
'
).
value
.
length
>
0
;
}
function
getHint
()
{
return
document
.
querySelector
(
'
.chat-textarea-hint
'
).
value
;
}
// The following line registers your plugin.
// The following line registers your plugin.
...
@@ -71,6 +61,10 @@
...
@@ -71,6 +61,10 @@
return
result
;
return
result
;
},
},
isEditSpoilerMessage
()
{
return
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
},
'
toggleSpoilerMessage
'
:
function
(
event
)
{
'
toggleSpoilerMessage
'
:
function
(
event
)
{
const
{
_converse
}
=
this
.
__super__
,
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
{
__
}
=
_converse
;
...
@@ -123,16 +117,7 @@
...
@@ -123,16 +117,7 @@
const
textArea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
textArea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
spoiler_button
=
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
);
const
spoiler_button
=
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
);
if
(
!
isEditSpoilerMessage
())
{
if
(
this
.
isEditSpoilerMessage
())
{
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Write your spoiler
\'
s content here
'
));
spoiler_button
.
setAttribute
(
"
active
"
,
"
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?
form
.
insertBefore
(
this
.
createHintTextArea
(),
textArea
);
// <textarea type="text" class="chat-textarea-hint " placeholder="Hint (optional)" style="background-color: rgb(188, 203, 209); height:30px;"></textarea>
}
else
{
textArea
.
style
[
'
background-color
'
]
=
''
;
textArea
.
style
[
'
background-color
'
]
=
''
;
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Personal message
'
));
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Personal message
'
));
spoiler_button
.
setAttribute
(
"
active
"
,
"
false
"
);
spoiler_button
.
setAttribute
(
"
active
"
,
"
false
"
);
...
@@ -141,19 +126,34 @@
...
@@ -141,19 +126,34 @@
if
(
hintTextArea
)
{
if
(
hintTextArea
)
{
hintTextArea
.
remove
();
hintTextArea
.
remove
();
}
}
}
else
{
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
textArea
.
setAttribute
(
'
placeholder
'
,
__
(
'
Write your spoiler
\'
s content here
'
));
spoiler_button
.
setAttribute
(
"
active
"
,
"
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?
form
.
insertBefore
(
this
.
createHintTextArea
(),
textArea
);
// <textarea type="text" class="chat-textarea-hint " placeholder="Hint (optional)" style="background-color: rgb(188, 203, 209); height:30px;"></textarea>
}
}
},
},
'
createMessageStanza
'
:
function
()
{
addSpoilerElement
(
stanza
)
{
const
messageStanza
=
this
.
__super__
.
createMessageStanza
.
apply
(
this
,
arguments
);
if
(
this
.
isEditSpoilerMessage
())
{
if
(
isEditSpoilerMessage
())
{
const
has_hint
=
this
.
el
.
querySelector
(
'
.chat-textarea-hint
'
).
value
.
length
>
0
;
if
(
hasHint
()){
if
(
has_hint
)
{
messageStanza
.
c
(
'
spoiler
'
,{
'
xmlns
'
:
'
urn:xmpp:spoiler:0
'
},
getHint
());
const
hint
=
document
.
querySelector
(
'
.chat-textarea-hint
'
).
value
;
stanza
.
c
(
'
spoiler
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
SPOILER
},
hint
);
}
else
{
}
else
{
messageStanza
.
c
(
'
spoiler
'
,{
'
xmlns
'
:
'
urn:xmpp:spoiler:0
'
});
stanza
.
c
(
'
spoiler
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
SPOILER
});
}
}
}
}
return
messageStanza
;
},
createMessageStanza
()
{
const
stanza
=
this
.
__super__
.
createMessageStanza
.
apply
(
this
,
arguments
);
this
.
addSpoilerElement
(
stanza
);
return
stanza
;
},
},
'
renderMessage
'
:
function
(
attrs
)
{
'
renderMessage
'
:
function
(
attrs
)
{
...
...
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