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
7f9f6247
Commit
7f9f6247
authored
Feb 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render spoiler button as a template
parent
ed33d4e5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
23 deletions
+46
-23
src/converse-chatview.js
src/converse-chatview.js
+3
-0
src/converse-spoilers.js
src/converse-spoilers.js
+39
-22
src/templates/chatarea.html
src/templates/chatarea.html
+1
-1
src/templates/spoiler_button.html
src/templates/spoiler_button.html
+3
-0
No files found.
src/converse-chatview.js
View file @
7f9f6247
...
@@ -308,6 +308,9 @@
...
@@ -308,6 +308,9 @@
return
this
;
return
this
;
},
},
renderTextArea
()
{
},
insertHeading
()
{
insertHeading
()
{
this
.
heading
=
new
_converse
.
ChatBoxHeading
({
'
model
'
:
this
.
model
});
this
.
heading
=
new
_converse
.
ChatBoxHeading
({
'
model
'
:
this
.
model
});
this
.
heading
.
render
();
this
.
heading
.
render
();
...
...
src/converse-spoilers.js
View file @
7f9f6247
(
function
(
root
,
factory
)
{
(
function
(
root
,
factory
)
{
define
([
"
converse-core
"
,
"
strophe.vcard
"
,
"
converse-chatview
"
],
factory
);
define
([
}(
this
,
function
(
converse
,
tpl_message
)
{
"
converse-core
"
,
"
tpl!spoiler_button
"
,
"
converse-chatview
"
],
factory
);
}(
this
,
function
(
converse
,
tpl_spoiler_button
)
{
const
{
_
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
function
isEditSpoilerMessage
()
{
function
isEditSpoilerMessage
()
{
return
document
.
querySelector
(
'
.toggle-spoiler-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
return
document
.
querySelector
(
'
.toggle-spoiler-edit
'
).
getAttribute
(
'
active
'
)
===
'
true
'
;
...
@@ -43,21 +50,37 @@
...
@@ -43,21 +50,37 @@
'
events
'
:
{
'
events
'
:
{
'
click .toggle-spoiler-edit
'
:
'
toggleEditSpoilerMessage
'
,
'
click .toggle-spoiler-edit
'
:
'
toggleEditSpoilerMessage
'
,
'
click .toggle-spoiler-display
'
:
'
toggleDisplaySpoilerMessage
'
'
click .toggle-spoiler-display
'
:
'
toggleSpoilerMessage
'
},
'
renderToolbar
'
:
function
(
toolbar
,
options
)
{
const
{
_converse
}
=
this
.
__super__
;
const
result
=
this
.
__super__
.
renderToolbar
.
apply
(
this
,
arguments
);
if
(
!
_converse
.
show_toolbar
)
{
return
result
;
}
const
html
=
tpl_spoiler_button
({
'
title
'
:
_converse
.
__
(
'
Click here to write a message as a spoiler
'
)
});
const
toolbar_el
=
this
.
el
.
querySelector
(
'
.chat-toolbar
'
);
if
(
!
_
.
isNull
(
toolbar_el
))
{
toolbar_el
.
appendChild
(
u
.
stringToElement
(
html
));
}
return
result
;
},
},
'
toggle
Display
SpoilerMessage
'
:
function
(
event
)
{
'
toggleSpoilerMessage
'
:
function
(
event
)
{
const
{
_converse
}
=
this
.
__super__
,
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
{
__
}
=
_converse
;
const
button
=
event
.
target
;
const
button
=
event
.
target
;
const
isClosed
=
button
.
getAttribute
(
"
closed
"
);
const
textarea
=
button
.
nextElementSibling
;
const
content
=
button
.
nextElementSibling
;
const
hint
=
textarea
.
children
[
0
];
const
hint
=
content
.
children
[
0
];
const
contentHidden
=
textarea
.
children
[
1
];
const
contentHidden
=
content
.
children
[
1
];
const
container
=
button
.
parentElement
;
const
container
=
button
.
parentElement
;
if
(
isClosed
==
"
true
"
)
{
//Show spoiler's content
if
(
button
.
getAttribute
(
"
closed
"
)
==
"
true
"
)
{
//Show spoiler's content
button
.
classList
.
remove
(
"
icon-eye
"
);
button
.
classList
.
remove
(
"
icon-eye
"
);
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
toggle-spoiler-display
"
);
button
.
classList
.
add
(
"
icon-eye-blocked
"
);
button
.
classList
.
add
(
"
icon-eye-blocked
"
);
...
@@ -94,9 +117,9 @@
...
@@ -94,9 +117,9 @@
const
{
_converse
}
=
this
.
__super__
,
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
{
__
}
=
_converse
;
const
form
=
document
.
querySelector
(
'
.sendXMPPMessage
'
);
const
form
=
this
.
el
.
querySelector
(
'
.sendXMPPMessage
'
);
const
textArea
=
document
.
querySelector
(
'
.chat-textarea
'
);
const
textArea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
spoiler_button
=
document
.
querySelector
(
'
.toggle-spoiler-edit
'
);
const
spoiler_button
=
this
.
el
.
querySelector
(
'
.toggle-spoiler-edit
'
);
if
(
!
isEditSpoilerMessage
())
{
if
(
!
isEditSpoilerMessage
())
{
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
textArea
.
style
[
'
background-color
'
]
=
'
#D5FFD2
'
;
...
@@ -229,17 +252,11 @@
...
@@ -229,17 +252,11 @@
/* Inside this method, you have access to the private
/* Inside this method, you have access to the private
* `_converse` object.
* `_converse` object.
*/
*/
const
{
_converse
}
=
this
,
const
{
_converse
}
=
this
;
{
__
}
=
_converse
;
function
initSpoilers
()
{
function
initSpoilers
(
chatbox
)
{
const
spoiler_button
=
document
.
createElement
(
'
li
'
);
chatbox
.
renderToolbar
();
spoiler_button
.
classList
.
add
(
"
toggle-spoiler-edit
"
);
spoiler_button
.
setAttribute
(
"
active
"
,
"
false
"
);
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
);
}
}
_converse
.
on
(
'
chatBoxFocused
'
,
initSpoilers
);
_converse
.
on
(
'
chatBoxFocused
'
,
initSpoilers
);
}
}
});
});
...
...
src/templates/chatarea.html
View file @
7f9f6247
src/templates/spoiler_button.html
0 → 100644
View file @
7f9f6247
<li
class=
"toggle-spoiler-edit"
data-active=
"false"
>
<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