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
14c66ff7
Commit
14c66ff7
authored
Feb 29, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also show HTML5 notifications for chat state changes.
updates #443
parent
578ca540
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
src/converse-core.js
src/converse-core.js
+4
-1
src/converse-notification.js
src/converse-notification.js
+33
-5
No files found.
src/converse-core.js
View file @
14c66ff7
...
@@ -882,6 +882,7 @@
...
@@ -882,6 +882,7 @@
this
.
RosterContact
=
Backbone
.
Model
.
extend
({
this
.
RosterContact
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attributes
,
options
)
{
initialize
:
function
(
attributes
,
options
)
{
var
jid
=
attributes
.
jid
;
var
jid
=
attributes
.
jid
;
var
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
);
var
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
);
...
@@ -1019,6 +1020,7 @@
...
@@ -1019,6 +1020,7 @@
this
.
RosterContacts
=
Backbone
.
Collection
.
extend
({
this
.
RosterContacts
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
RosterContact
,
model
:
converse
.
RosterContact
,
comparator
:
function
(
contact1
,
contact2
)
{
comparator
:
function
(
contact1
,
contact2
)
{
var
name1
,
name2
;
var
name1
,
name2
;
var
status1
=
contact1
.
get
(
'
chat_status
'
)
||
'
offline
'
;
var
status1
=
contact1
.
get
(
'
chat_status
'
)
||
'
offline
'
;
...
@@ -2124,6 +2126,7 @@
...
@@ -2124,6 +2126,7 @@
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
}
}
}
}
// FIXME: multiple parameters not accepted?
converse
.
emit
(
'
contactStatusChanged
'
,
item
.
attributes
,
item
.
get
(
'
chat_status
'
));
converse
.
emit
(
'
contactStatusChanged
'
,
item
.
attributes
,
item
.
get
(
'
chat_status
'
));
},
},
...
...
src/converse-notification.js
View file @
14c66ff7
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
notifyOfNewMessage
:
function
(
$message
)
{
notifyOfNewMessage
:
function
(
$message
)
{
var
result
=
this
.
_super
.
notifyOfNewMessage
.
apply
(
this
,
arguments
);
var
result
=
this
.
_super
.
notifyOfNewMessage
.
apply
(
this
,
arguments
);
if
(
result
&&
(
this
.
windowState
===
'
blur
'
)
&&
(
Notification
.
permission
===
"
granted
"
))
{
if
(
result
&&
(
this
.
windowState
===
'
blur
'
)
&&
(
Notification
.
permission
===
"
granted
"
))
{
this
.
showNotification
(
$message
);
this
.
show
Message
Notification
(
$message
);
}
}
return
result
;
return
result
;
}
}
...
@@ -51,7 +51,35 @@
...
@@ -51,7 +51,35 @@
*/
*/
var
converse
=
this
.
converse
;
var
converse
=
this
.
converse
;
converse
.
showNotification
=
function
(
$message
)
{
converse
.
showChatStateNotification
=
function
(
event
,
contact
)
{
/* Show an HTML5 notification indicating that a contact changed
* their chat state.
*/
var
chat_state
=
contact
.
chat_status
,
message
=
null
;
if
(
chat_state
===
'
offline
'
)
{
message
=
__
(
'
has gone offline
'
);
}
else
if
(
chat_state
===
'
away
'
)
{
message
=
__
(
'
has gone away
'
);
}
else
if
((
chat_state
===
'
dnd
'
))
{
message
=
__
(
'
is busy
'
);
}
else
if
(
chat_state
===
'
online
'
)
{
message
=
__
(
'
has come online
'
);
}
if
(
message
===
null
)
{
return
;
}
var
n
=
new
Notification
(
contact
.
fullname
,
{
body
:
message
,
lang
:
converse
.
i18n
.
locale_data
.
converse
[
""
].
lang
,
icon
:
'
logo/conversejs.png
'
});
setTimeout
(
n
.
close
.
bind
(
n
),
5000
);
};
converse
.
on
(
'
contactStatusChanged
'
,
converse
.
showChatStateNotification
);
converse
.
showMessageNotification
=
function
(
$message
)
{
/* Show an HTML5 notification of a received message.
/* Show an HTML5 notification of a received message.
*/
*/
var
contact_jid
=
Strophe
.
getBareJidFromJid
(
$message
.
attr
(
'
from
'
));
var
contact_jid
=
Strophe
.
getBareJidFromJid
(
$message
.
attr
(
'
from
'
));
...
...
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