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
588ff50a
Commit
588ff50a
authored
Jul 14, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add status notifications to any open chatboxes.
parent
b304a54a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
+34
-15
chat.js
chat.js
+34
-15
No files found.
chat.js
View file @
588ff50a
...
@@ -175,6 +175,13 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -175,6 +175,13 @@ xmppchat.ChatBoxView = Backbone.View.extend({
$chat_content
.
scrollTop
(
$chat_content
[
0
].
scrollHeight
);
$chat_content
.
scrollTop
(
$chat_content
[
0
].
scrollHeight
);
},
},
insertStatusNotification
:
function
(
message
)
{
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
$chat_content
.
find
(
'
div.chat-event
'
).
remove
().
end
()
.
append
(
$
(
'
<div class="chat-event"></div>
'
).
text
(
this
.
model
.
get
(
'
user_id
'
)
+
'
'
+
message
));
$chat_content
.
scrollTop
(
$chat_content
[
0
].
scrollHeight
);
},
messageReceived
:
function
(
message
)
{
messageReceived
:
function
(
message
)
{
/* XXX: event.mtype should be 'xhtml' for XHTML-IM messages,
/* XXX: event.mtype should be 'xhtml' for XHTML-IM messages,
but I only seem to get 'text'.
but I only seem to get 'text'.
...
@@ -189,8 +196,8 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -189,8 +196,8 @@ xmppchat.ChatBoxView = Backbone.View.extend({
if
(
!
body
)
{
if
(
!
body
)
{
if
(
composing
.
length
>
0
)
{
if
(
composing
.
length
>
0
)
{
$chat_content
.
find
(
'
div.chat-event
'
).
remove
().
end
()
this
.
insertStatusNotification
(
'
is typing
'
);
.
append
(
$
(
'
<div class="chat-event"></div>
'
).
text
(
user_id
+
'
is typing...
'
))
;
return
;
}
}
}
else
{
}
else
{
// TODO: ClientStorage
// TODO: ClientStorage
...
@@ -212,8 +219,8 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -212,8 +219,8 @@ xmppchat.ChatBoxView = Backbone.View.extend({
// TODO:
// TODO:
// xmppchat.UI.msg_counter += 1;
// xmppchat.UI.msg_counter += 1;
// xmppchat.UI.updateMsgCounter();
// xmppchat.UI.updateMsgCounter();
$chat_content
.
scrollTop
(
$chat_content
[
0
].
scrollHeight
);
}
}
$chat_content
.
scrollTop
(
$chat_content
[
0
].
scrollHeight
);
},
},
insertClientStoredMessages
:
function
()
{
insertClientStoredMessages
:
function
()
{
...
@@ -343,6 +350,22 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -343,6 +350,22 @@ xmppchat.ChatBoxView = Backbone.View.extend({
initialize
:
function
(){
initialize
:
function
(){
$
(
'
body
'
).
append
(
$
(
this
.
el
).
hide
());
$
(
'
body
'
).
append
(
$
(
this
.
el
).
hide
());
xmppchat
.
roster
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
if
(
_
.
has
(
changed
.
changes
,
'
status
'
))
{
if
(
this
.
$el
.
is
(
'
:visible
'
))
{
if
(
item
.
get
(
'
status
'
)
===
'
offline
'
)
{
this
.
insertStatusNotification
(
'
has gone offline
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
away
'
)
{
this
.
insertStatusNotification
(
'
has gone away
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
busy
'
)
{
this
.
insertStatusNotification
(
'
is busy
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
online
'
)
{
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
}
}
}
},
this
);
},
},
template
:
_
.
template
(
'
<div class="chat-head chat-head-chatbox">
'
+
template
:
_
.
template
(
'
<div class="chat-head chat-head-chatbox">
'
+
...
@@ -555,7 +578,7 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
...
@@ -555,7 +578,7 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
}
}
view
.
messageReceived
(
message
);
view
.
messageReceived
(
message
);
// XXX: Is this the right place for this? Perhaps an event?
// XXX: Is this the right place for this? Perhaps an event?
xmppchat
.
R
oster
.
addResource
(
bare_jid
,
resource
);
xmppchat
.
r
oster
.
addResource
(
bare_jid
,
resource
);
},
},
initialize
:
function
()
{
initialize
:
function
()
{
...
@@ -624,7 +647,7 @@ xmppchat.RosterItemView = Backbone.View.extend({
...
@@ -624,7 +647,7 @@ xmppchat.RosterItemView = Backbone.View.extend({
});
});
xmppchat
.
Roster
Class
=
(
function
(
stropheRoster
,
_
,
$
,
console
)
{
xmppchat
.
Roster
=
(
function
(
stropheRoster
,
_
,
$
,
console
)
{
var
ob
=
_
.
clone
(
stropheRoster
),
var
ob
=
_
.
clone
(
stropheRoster
),
Collection
=
Backbone
.
Collection
.
extend
({
Collection
=
Backbone
.
Collection
.
extend
({
model
:
xmppchat
.
RosterItem
,
model
:
xmppchat
.
RosterItem
,
...
@@ -769,7 +792,7 @@ xmppchat.RosterClass = (function (stropheRoster, _, $, console) {
...
@@ -769,7 +792,7 @@ xmppchat.RosterClass = (function (stropheRoster, _, $, console) {
stropheRoster
.
subscribe
(
bare_jid
);
stropheRoster
.
subscribe
(
bare_jid
);
}
else
if
(
ptype
===
'
unsubscribe
'
)
{
}
else
if
(
ptype
===
'
unsubscribe
'
)
{
if
(
_
.
indexOf
(
xmppchat
.
R
oster
.
getCachedJids
(),
bare_jid
)
!=
-
1
)
{
if
(
_
.
indexOf
(
xmppchat
.
r
oster
.
getCachedJids
(),
bare_jid
)
!=
-
1
)
{
stropheRoster
.
unauthorize
(
bare_jid
);
stropheRoster
.
unauthorize
(
bare_jid
);
stropheRoster
.
unsubscribe
(
bare_jid
);
stropheRoster
.
unsubscribe
(
bare_jid
);
}
}
...
@@ -925,19 +948,15 @@ $(document).ready(function () {
...
@@ -925,19 +948,15 @@ $(document).ready(function () {
$
(
document
).
unbind
(
'
jarnxmpp.connected
'
);
$
(
document
).
unbind
(
'
jarnxmpp.connected
'
);
$
(
document
).
bind
(
'
jarnxmpp.connected
'
,
function
()
{
$
(
document
).
bind
(
'
jarnxmpp.connected
'
,
function
()
{
// FIXME: Need to get some convention going for naming classes and instances of
// models and views.
xmppchat
.
connection
.
bare_jid
=
Strophe
.
getBareJidFromJid
(
xmppchat
.
connection
.
jid
);
xmppchat
.
connection
.
bare_jid
=
Strophe
.
getBareJidFromJid
(
xmppchat
.
connection
.
jid
);
// Messages
xmppchat
.
roster
=
xmppchat
.
Roster
(
Strophe
.
_connectionPlugins
.
roster
,
_
,
$
,
console
);
xmppchat
.
rosterview
=
Backbone
.
View
.
extend
(
xmppchat
.
RosterView
(
xmppchat
.
roster
,
_
,
$
,
console
));
xmppchat
.
Roster
=
xmppchat
.
RosterClass
(
Strophe
.
_connectionPlugins
.
roster
,
_
,
$
,
console
);
xmppchat
.
rosterview
=
Backbone
.
View
.
extend
(
xmppchat
.
RosterView
(
xmppchat
.
Roster
,
_
,
$
,
console
));
xmppchat
.
connection
.
addHandler
(
xmppchat
.
R
oster
.
presenceHandler
,
null
,
'
presence
'
,
null
);
xmppchat
.
connection
.
addHandler
(
xmppchat
.
r
oster
.
presenceHandler
,
null
,
'
presence
'
,
null
);
xmppchat
.
Roster
.
registerCallback
(
xmppchat
.
R
oster
.
updateHandler
);
xmppchat
.
roster
.
registerCallback
(
xmppchat
.
r
oster
.
updateHandler
);
xmppchat
.
R
oster
.
getRoster
();
xmppchat
.
r
oster
.
getRoster
();
xmppchat
.
chatboxes
=
new
xmppchat
.
ChatBoxes
();
xmppchat
.
chatboxes
=
new
xmppchat
.
ChatBoxes
();
...
...
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