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
86f3399d
Commit
86f3399d
authored
May 14, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also trigger 'chatboxFocused' when user manually focuses
parent
dd082107
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
23 deletions
+19
-23
spec/chatbox.js
spec/chatbox.js
+0
-3
src/converse-chatview.js
src/converse-chatview.js
+19
-20
No files found.
spec/chatbox.js
View file @
86f3399d
...
@@ -123,7 +123,6 @@
...
@@ -123,7 +123,6 @@
// Check that new chat boxes are created to the left of the
// Check that new chat boxes are created to the left of the
// controlbox (but to the right of all existing chat boxes)
// controlbox (but to the right of all existing chat boxes)
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
2
);
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
2
);
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
)[
1
].
id
).
toBe
(
chatboxview
.
model
.
get
(
'
box_id
'
));
online_contacts
[
1
].
click
();
online_contacts
[
1
].
click
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
3
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
3
);
el
=
online_contacts
[
1
];
el
=
online_contacts
[
1
];
...
@@ -133,8 +132,6 @@
...
@@ -133,8 +132,6 @@
// Check that new chat boxes are created to the left of the
// Check that new chat boxes are created to the left of the
// controlbox (but to the right of all existing chat boxes)
// controlbox (but to the right of all existing chat boxes)
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
3
);
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
3
);
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
)[
2
].
id
).
toBe
(
chatboxview
.
model
.
get
(
'
box_id
'
));
expect
(
document
.
querySelectorAll
(
"
#conversejs .chatbox
"
)[
1
].
id
).
toBe
(
new_chatboxview
.
model
.
get
(
'
box_id
'
));
done
();
done
();
}));
}));
...
...
src/converse-chatview.js
View file @
86f3399d
...
@@ -366,13 +366,12 @@ converse.plugins.add('converse-chatview', {
...
@@ -366,13 +366,12 @@ converse.plugins.add('converse-chatview', {
},
},
render
()
{
render
()
{
// XXX: Is this still needed?
this
.
el
.
setAttribute
(
'
id
'
,
this
.
model
.
get
(
'
box_id
'
));
this
.
el
.
innerHTML
=
tpl_chatbox
(
this
.
el
.
innerHTML
=
tpl_chatbox
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
Object
.
assign
(
'
unread_msgs
'
:
__
(
'
You have unread messages
'
)
this
.
model
.
toJSON
(),
}
{
'
unread_msgs
'
:
__
(
'
You have unread messages
'
)}
));
)
);
this
.
content
=
this
.
el
.
querySelector
(
'
.chat-content
'
);
this
.
content
=
this
.
el
.
querySelector
(
'
.chat-content
'
);
this
.
renderMessageForm
();
this
.
renderMessageForm
();
this
.
insertHeading
();
this
.
insertHeading
();
...
@@ -402,17 +401,11 @@ converse.plugins.add('converse-chatview', {
...
@@ -402,17 +401,11 @@ converse.plugins.add('converse-chatview', {
},
},
renderMessageForm
()
{
renderMessageForm
()
{
let
placeholder
;
if
(
this
.
model
.
get
(
'
composing_spoiler
'
))
{
placeholder
=
__
(
'
Hidden message
'
);
}
else
{
placeholder
=
__
(
'
Message
'
);
}
const
form_container
=
this
.
el
.
querySelector
(
'
.bottom-panel
'
);
const
form_container
=
this
.
el
.
querySelector
(
'
.bottom-panel
'
);
form_container
.
innerHTML
=
tpl_chatbox_message_form
(
form_container
.
innerHTML
=
tpl_chatbox_message_form
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
Object
.
assign
(
this
.
model
.
toJSON
(),
{
'
hint_value
'
:
_
.
get
(
this
.
el
.
querySelector
(
'
.spoiler-hint
'
),
'
value
'
),
'
hint_value
'
:
_
.
get
(
this
.
el
.
querySelector
(
'
.spoiler-hint
'
),
'
value
'
),
'
label_message
'
:
placeholder
,
'
label_message
'
:
this
.
model
.
get
(
'
composing_spoiler
'
)
?
__
(
'
Hidden message
'
)
:
__
(
'
Message
'
)
,
'
label_send
'
:
__
(
'
Send
'
),
'
label_send
'
:
__
(
'
Send
'
),
'
label_spoiler_hint
'
:
__
(
'
Optional hint
'
),
'
label_spoiler_hint
'
:
__
(
'
Optional hint
'
),
'
message_value
'
:
_
.
get
(
this
.
el
.
querySelector
(
'
.chat-textarea
'
),
'
value
'
),
'
message_value
'
:
_
.
get
(
this
.
el
.
querySelector
(
'
.chat-textarea
'
),
'
value
'
),
...
@@ -420,6 +413,8 @@ converse.plugins.add('converse-chatview', {
...
@@ -420,6 +413,8 @@ converse.plugins.add('converse-chatview', {
'
show_toolbar
'
:
_converse
.
show_toolbar
,
'
show_toolbar
'
:
_converse
.
show_toolbar
,
'
unread_msgs
'
:
__
(
'
You have unread messages
'
)
'
unread_msgs
'
:
__
(
'
You have unread messages
'
)
}));
}));
const
textarea_el
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
textarea_el
.
addEventListener
(
'
focus
'
,
()
=>
this
.
emitFocused
());
this
.
renderToolbar
();
this
.
renderToolbar
();
},
},
...
@@ -1256,10 +1251,7 @@ converse.plugins.add('converse-chatview', {
...
@@ -1256,10 +1251,7 @@ converse.plugins.add('converse-chatview', {
}
}
},
},
focus
()
{
emitFocused
:
_
.
debounce
(()
=>
{
const
textarea_el
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
if
(
!
_
.
isNull
(
textarea_el
))
{
textarea_el
.
focus
();
/**
/**
* Triggered when the focus has been moved to a particular chat.
* Triggered when the focus has been moved to a particular chat.
* @event _converse#chatBoxFocused
* @event _converse#chatBoxFocused
...
@@ -1267,6 +1259,13 @@ converse.plugins.add('converse-chatview', {
...
@@ -1267,6 +1259,13 @@ converse.plugins.add('converse-chatview', {
* @example _converse.api.listen.on('chatBoxFocused', view => { ... });
* @example _converse.api.listen.on('chatBoxFocused', view => { ... });
*/
*/
_converse
.
api
.
trigger
(
'
chatBoxFocused
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxFocused
'
,
this
);
},
25
,
{
'
leading
'
:
true
}),
focus
()
{
const
textarea_el
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
if
(
!
_
.
isNull
(
textarea_el
))
{
textarea_el
.
focus
();
this
.
emitFocused
();
}
}
return
this
;
return
this
;
},
},
...
...
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