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
824b2c81
Commit
824b2c81
authored
Jun 26, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converse-minimize: Rename view methods to clarify
that they are in response to a change and not meant as an API.
parent
bd81b897
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
19 deletions
+27
-19
spec/chatbox.js
spec/chatbox.js
+2
-2
src/converse-minimize.js
src/converse-minimize.js
+25
-17
No files found.
spec/chatbox.js
View file @
824b2c81
...
...
@@ -211,10 +211,10 @@
const
el
=
online_contacts
[
i
];
jid
=
_
.
trim
(
el
.
textContent
.
trim
()).
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
spyOn
(
chatboxview
,
'
minimize
'
).
and
.
callThrough
();
spyOn
(
chatboxview
,
'
onMinimized
'
).
and
.
callThrough
();
chatboxview
.
model
.
set
({
'
minimized
'
:
true
});
expect
(
trimmed_chatboxes
.
addChat
).
toHaveBeenCalled
();
expect
(
chatboxview
.
minimize
).
toHaveBeenCalled
();
expect
(
chatboxview
.
onMinimized
).
toHaveBeenCalled
();
}
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
keys
().
length
);
var
key
=
_converse
.
chatboxviews
.
keys
()[
1
];
...
...
src/converse-minimize.js
View file @
824b2c81
...
...
@@ -84,7 +84,7 @@ converse.plugins.add('converse-minimize', {
this
.
__super__
.
_show
.
apply
(
this
,
arguments
);
_converse
.
chatboxviews
.
trimChats
(
this
);
}
else
{
this
.
minimize
();
this
.
m
odel
.
m
inimize
();
}
},
...
...
@@ -135,13 +135,7 @@ converse.plugins.add('converse-minimize', {
},
initialize
()
{
this
.
model
.
on
(
'
change:minimized
'
,
function
(
item
)
{
if
(
item
.
get
(
'
minimized
'
))
{
this
.
hide
();
}
else
{
this
.
maximize
();
}
},
this
);
this
.
model
.
on
(
'
change:minimized
'
,
this
.
onMinimizedChanged
,
this
);
const
result
=
this
.
__super__
.
initialize
.
apply
(
this
,
arguments
);
if
(
this
.
model
.
get
(
'
minimized
'
))
{
this
.
hide
();
...
...
@@ -197,20 +191,22 @@ converse.plugins.add('converse-minimize', {
const
minimizableChatBoxView
=
{
/**
* Maximizes a minimized chat box.
* Handler which gets called when a {@link _converse#ChatBox} has it's
* `minimized` property set to false.
*
* Will trigger {@link _converse#chatBoxMaximized}
* @private
* @returns {_converse.ChatBoxView|_converse.ChatRoomView}
*/
maximize
()
{
// Restores a minimized chat box
onMaximized
()
{
const
{
_converse
}
=
this
.
__super__
;
this
.
insertIntoDOM
();
if
(
!
this
.
model
.
isScrolledUp
())
{
this
.
model
.
clearUnreadMsgCounter
();
}
this
.
setChatState
(
_converse
.
INACTIVE
);
this
.
show
();
/**
* Triggered when a previously minimized chat gets maximized
...
...
@@ -223,11 +219,14 @@ converse.plugins.add('converse-minimize', {
},
/**
* Minimizes a chat box.
* Handler which gets called when a {@link _converse#ChatBox} has it's
* `minimized` property set to true.
*
* Will trigger {@link _converse#chatBoxMinimized}
* @private
* @returns {_converse.ChatBoxView|_converse.ChatRoomView}
*/
minimize
(
ev
)
{
onMinimized
(
ev
)
{
const
{
_converse
}
=
this
.
__super__
;
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
// save the scroll position to restore it on maximize
...
...
@@ -236,7 +235,7 @@ converse.plugins.add('converse-minimize', {
}
else
{
this
.
model
.
set
({
'
scroll
'
:
this
.
content
.
scrollTop
});
}
this
.
setChatState
(
_converse
.
INACTIVE
)
.
model
.
minimize
()
;
this
.
setChatState
(
_converse
.
INACTIVE
);
this
.
hide
();
/**
* Triggered when a previously maximized chat gets Minimized
...
...
@@ -248,11 +247,20 @@ converse.plugins.add('converse-minimize', {
return
this
;
},
/**
* Minimizes a chat box.
* @returns {_converse.ChatBoxView|_converse.ChatRoomView}
*/
minimize
(
ev
)
{
this
.
model
.
minimize
();
return
this
;
},
onMinimizedChanged
(
item
)
{
if
(
item
.
get
(
'
minimized
'
))
{
this
.
minimize
();
this
.
onMinimized
();
}
else
{
this
.
maximize
();
this
.
onMaximized
();
}
}
}
...
...
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