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
19979c48
Commit
19979c48
authored
Dec 19, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Listen to `animationend` event instead of using setTimeout
parent
d1fe6595
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
38 deletions
+36
-38
spec/chatbox.js
spec/chatbox.js
+2
-3
src/converse-chatview.js
src/converse-chatview.js
+21
-17
src/utils.js
src/utils.js
+13
-18
No files found.
spec/chatbox.js
View file @
19979c48
...
...
@@ -1569,9 +1569,8 @@
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
rosterview
.
$el
.
find
(
'
.roster-group
'
).
length
;
},
300
)
.
then
(
function
()
{
return
_converse
.
rosterview
.
$el
.
find
(
'
.roster-group
'
).
length
;
},
300
).
then
(
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
var
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
...
src/converse-chatview.js
View file @
19979c48
...
...
@@ -40,8 +40,8 @@
tpl_spinner
)
{
"
use strict
"
;
const
{
$msg
,
Backbone
,
Strophe
,
_
,
b64_sha1
,
moment
,
utils
}
=
converse
.
env
;
const
{
$msg
,
Backbone
,
Strophe
,
_
,
b64_sha1
,
moment
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
KEY
=
{
ENTER
:
13
,
FORWARD_SLASH
:
47
...
...
@@ -64,7 +64,7 @@
_
.
includes
(
ev
.
target
.
classList
,
'
insert-emoji
'
))
{
return
;
}
u
tils
.
slideInAllElements
(
u
.
slideInAllElements
(
document
.
querySelectorAll
(
'
.toolbar-menu
'
)
)
}
...
...
@@ -147,8 +147,8 @@
_
.
extend
(
this
.
model
.
toJSON
(),
{
'
transform
'
:
_converse
.
use_emojione
?
emojione
.
shortnameToImage
:
emojione
.
shortnameToUnicode
,
'
emojis_by_category
'
:
u
tils
.
getEmojisByCategory
(
_converse
,
emojione
),
'
toned_emojis
'
:
u
tils
.
getTonedEmojis
(
_converse
),
'
emojis_by_category
'
:
u
.
getEmojisByCategory
(
_converse
,
emojione
),
'
toned_emojis
'
:
u
.
getTonedEmojis
(
_converse
),
'
skintones
'
:
[
'
tone1
'
,
'
tone2
'
,
'
tone3
'
,
'
tone4
'
,
'
tone5
'
],
'
shouldBeHidden
'
:
this
.
shouldBeHidden
}
...
...
@@ -275,7 +275,7 @@
this
.
model
.
on
(
'
sendMessage
'
,
this
.
sendMessage
,
this
);
this
.
render
().
renderToolbar
().
insertHeading
().
fetchMessages
();
u
tils
.
refreshWebkit
();
u
.
refreshWebkit
();
_converse
.
emit
(
'
chatBoxOpened
'
,
this
);
_converse
.
emit
(
'
chatBoxInitialized
'
,
this
);
},
...
...
@@ -545,10 +545,10 @@
})
));
const
msg_content
=
$msg
[
0
].
querySelector
(
'
.chat-msg-content
'
);
msg_content
.
innerHTML
=
u
tils
.
addEmoji
(
_converse
,
emojione
,
u
tils
.
addHyperlinks
(
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}}))
msg_content
.
innerHTML
=
u
.
addEmoji
(
_converse
,
emojione
,
u
.
addHyperlinks
(
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}}))
);
u
tils
.
renderImageURLs
(
msg_content
);
u
.
renderImageURLs
(
msg_content
);
return
$msg
;
},
...
...
@@ -600,14 +600,14 @@
handleTextMessage
(
message
)
{
this
.
showMessage
(
_
.
clone
(
message
.
attributes
));
if
(
u
tils
.
isNewMessage
(
message
)
&&
message
.
get
(
'
sender
'
)
===
'
me
'
)
{
if
(
u
.
isNewMessage
(
message
)
&&
message
.
get
(
'
sender
'
)
===
'
me
'
)
{
// We remove the "scrolled" flag so that the chat area
// gets scrolled down. We always want to scroll down
// when the user writes a message as opposed to when a
// message is received.
this
.
model
.
set
(
'
scrolled
'
,
false
);
}
else
{
if
(
u
tils
.
isNewMessage
(
message
)
&&
this
.
model
.
get
(
'
scrolled
'
,
true
))
{
if
(
u
.
isNewMessage
(
message
)
&&
this
.
model
.
get
(
'
scrolled
'
,
true
))
{
this
.
$el
.
find
(
'
.new-msgs-indicator
'
).
removeClass
(
'
hidden
'
);
}
}
...
...
@@ -833,9 +833,9 @@
document
.
querySelectorAll
(
'
.toolbar-menu
'
),
[
this
.
emoji_picker_view
.
el
]
);
u
tils
.
slideInAllElements
(
elements
)
u
.
slideInAllElements
(
elements
)
.
then
(
_
.
partial
(
u
tils
.
slideToggleElement
,
u
.
slideToggleElement
,
this
.
emoji_picker_view
.
el
))
.
then
(
this
.
focus
.
bind
(
this
));
},
...
...
@@ -920,12 +920,12 @@
hide
()
{
this
.
el
.
classList
.
add
(
'
hidden
'
);
u
tils
.
refreshWebkit
();
u
.
refreshWebkit
();
return
this
;
},
afterShown
(
focus
)
{
if
(
u
tils
.
isPersistableModel
(
this
.
model
))
{
if
(
u
.
isPersistableModel
(
this
.
model
))
{
this
.
model
.
save
();
}
this
.
setChatState
(
_converse
.
ACTIVE
);
...
...
@@ -941,7 +941,11 @@
if
(
focus
)
{
this
.
focus
();
}
return
;
}
utils
.
fadeIn
(
this
.
el
,
_
.
bind
(
this
.
afterShown
,
this
,
focus
));
const
that
=
this
;
u
.
fadeIn
(
this
.
el
,
function
()
{
that
.
afterShown
();
if
(
focus
)
{
that
.
focus
();
}
});
},
show
(
focus
)
{
...
...
@@ -987,7 +991,7 @@
scrolled
=
false
;
this
.
onScrolledDown
();
}
u
tils
.
safeSave
(
this
.
model
,
{
'
scrolled
'
:
scrolled
});
u
.
safeSave
(
this
.
model
,
{
'
scrolled
'
:
scrolled
});
},
viewUnreadMessages
()
{
...
...
src/utils.js
View file @
19979c48
...
...
@@ -35,13 +35,6 @@
'
warn
'
:
_
.
get
(
console
,
'
log
'
)
?
console
.
log
.
bind
(
console
)
:
_
.
noop
},
console
);
var
afterAnimationEnd
=
function
(
el
,
callback
)
{
el
.
classList
.
remove
(
'
visible
'
);
if
(
_
.
isFunction
(
callback
))
{
callback
();
}
};
var
unescapeHTML
=
function
(
htmlEscapedText
)
{
/* Helper method that replace HTML-escaped symbols with equivalent characters
* (e.g. transform occurrences of '&' to '&')
...
...
@@ -287,27 +280,29 @@
});
};
function
afterAnimationEnds
(
el
,
callback
)
{
el
.
classList
.
remove
(
'
visible
'
);
if
(
_
.
isFunction
(
callback
))
{
callback
();
}
}
u
.
fadeIn
=
function
(
el
,
callback
)
{
if
(
_
.
isNil
(
el
))
{
logger
.
warn
(
"
Undefined or null element passed into fadeIn
"
);
}
if
(
window
.
converse_disable_effects
)
{
// Effects are disabled (for tests)
if
(
window
.
converse_disable_effects
)
{
el
.
classList
.
remove
(
'
hidden
'
);
if
(
_
.
isFunction
(
callback
))
{
callback
();
}
return
;
return
afterAnimationEnds
(
el
,
callback
);
}
if
(
_
.
includes
(
el
.
classList
,
'
hidden
'
))
{
/* XXX: This doesn't appear to be working...
el.addEventListener("webkitAnimationEnd", _.partial(afterAnimationEnd, el, callback), false);
el.addEventListener("animationend", _.partial(afterAnimationEnd, el, callback), false);
*/
setTimeout
(
_
.
partial
(
afterAnimationEnd
,
el
,
callback
),
351
);
el
.
classList
.
add
(
'
visible
'
);
el
.
classList
.
remove
(
'
hidden
'
);
el
.
addEventListener
(
"
webkitAnimationEnd
"
,
_
.
partial
(
afterAnimationEnds
,
el
,
callback
));
el
.
addEventListener
(
"
animationend
"
,
_
.
partial
(
afterAnimationEnds
,
el
,
callback
));
el
.
addEventListener
(
"
oanimationend
"
,
_
.
partial
(
afterAnimationEnds
,
el
,
callback
));
}
else
{
afterAnimationEnd
(
el
,
callback
);
afterAnimationEnd
s
(
el
,
callback
);
}
};
...
...
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