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
51d0f7d8
Commit
51d0f7d8
authored
Sep 29, 2013
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/jcbrand/converse.js
parents
155b8e6a
e4a1ccf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
43 deletions
+70
-43
converse.js
converse.js
+70
-43
No files found.
converse.js
View file @
51d0f7d8
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
var
UNVERIFIED
=
1
;
var
UNVERIFIED
=
1
;
var
VERIFIED
=
2
;
var
VERIFIED
=
2
;
var
FINISHED
=
3
;
var
FINISHED
=
3
;
var
KEY
=
{
ENTER
:
13
};
// Default values
// Default values
var
converse
=
this
;
var
converse
=
this
;
...
@@ -785,7 +788,7 @@
...
@@ -785,7 +788,7 @@
keyPressed
:
function
(
ev
)
{
keyPressed
:
function
(
ev
)
{
var
$textarea
=
$
(
ev
.
target
),
var
$textarea
=
$
(
ev
.
target
),
message
,
notify
,
composing
;
message
,
notify
,
composing
;
if
(
ev
.
keyCode
==
13
)
{
if
(
ev
.
keyCode
==
KEY
.
ENTER
)
{
ev
.
preventDefault
();
ev
.
preventDefault
();
message
=
$textarea
.
val
();
message
=
$textarea
.
val
();
$textarea
.
val
(
''
).
focus
();
$textarea
.
val
(
''
).
focus
();
...
@@ -2242,6 +2245,28 @@
...
@@ -2242,6 +2245,28 @@
var
item
=
this
.
model
,
var
item
=
this
.
model
,
ask
=
item
.
get
(
'
ask
'
),
ask
=
item
.
get
(
'
ask
'
),
subscription
=
item
.
get
(
'
subscription
'
);
subscription
=
item
.
get
(
'
subscription
'
);
var
statuses
=
{
'
dnd
'
:
__
(
'
This contact is busy
'
),
'
online
'
:
__
(
'
This contact is online
'
),
'
offline
'
:
__
(
'
This contact is offline
'
),
'
unavailable
'
:
__
(
'
This contact is unavailable
'
),
'
xa
'
:
__
(
'
This contact is away for an extended period
'
),
'
away
'
:
__
(
'
This contact is away
'
)
}
var
classes_to_remove
=
[
'
current-xmpp-contact
'
,
'
pending-xmpp-contact
'
,
'
requesting-xmpp-contact
'
].
concat
(
_
.
keys
(
statuses
));
_
.
each
(
classes_to_remove
,
function
(
cls
)
{
if
(
this
.
el
.
className
.
indexOf
(
cls
)
!==
-
1
)
{
this
.
$el
.
removeClass
(
cls
);
}
},
this
);
this
.
$el
.
addClass
(
item
.
get
(
'
chat_status
'
));
this
.
$el
.
addClass
(
item
.
get
(
'
chat_status
'
));
if
(
ask
===
'
subscribe
'
)
{
if
(
ask
===
'
subscribe
'
)
{
...
@@ -2252,56 +2277,53 @@
...
@@ -2252,56 +2277,53 @@
this
.
$el
.
html
(
this
.
request_template
(
item
.
toJSON
()));
this
.
$el
.
html
(
this
.
request_template
(
item
.
toJSON
()));
converse
.
showControlBox
();
converse
.
showControlBox
();
}
else
if
(
subscription
===
'
both
'
||
subscription
===
'
to
'
)
{
}
else
if
(
subscription
===
'
both
'
||
subscription
===
'
to
'
)
{
_
.
each
([
'
pending-xmpp-contact
'
,
'
requesting-xmpp-contact
'
],
function
(
cls
)
{
if
(
this
.
el
.
className
.
indexOf
(
cls
)
!==
-
1
)
{
this
.
$el
.
removeClass
(
cls
);
}
},
this
);
this
.
$el
.
addClass
(
'
current-xmpp-contact
'
);
this
.
$el
.
addClass
(
'
current-xmpp-contact
'
);
var
status_desc
=
{
'
dnd
'
:
__
(
'
This contact is busy
'
),
'
online
'
:
__
(
'
This contact is online
'
),
'
offline
'
:
__
(
'
This contact is offline
'
),
'
unavailable
'
:
__
(
'
This contact is unavailable
'
),
'
xa
'
:
__
(
'
This contact is away for an extended period
'
),
'
away
'
:
__
(
'
This contact is away
'
)
}[
item
.
get
(
'
chat_status
'
)
||
'
offline
'
];
this
.
$el
.
html
(
this
.
template
(
this
.
$el
.
html
(
this
.
template
(
_
.
extend
(
item
.
toJSON
(),
{
'
status_desc
'
:
status
_desc
})
_
.
extend
(
item
.
toJSON
(),
{
'
status_desc
'
:
status
es
[
item
.
get
(
'
chat_status
'
)
||
'
offline
'
]
})
));
));
}
}
return
this
;
return
this
;
},
},
initialize
:
function
()
{
this
.
options
.
model
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
if
(
_
.
has
(
item
.
changed
,
'
chat_status
'
))
{
this
.
$el
.
attr
(
'
class
'
,
item
.
changed
.
chat_status
);
}
},
this
);
}
});
});
this
.
getVCard
=
function
(
jid
,
callback
,
errback
)
{
this
.
getVCard
=
function
(
jid
,
callback
,
errback
)
{
converse
.
connection
.
vcard
.
get
(
$
.
proxy
(
function
(
iq
)
{
converse
.
connection
.
vcard
.
get
(
$vcard
=
$
(
iq
).
find
(
'
vCard
'
);
$
.
proxy
(
function
(
iq
)
{
var
fullname
=
$vcard
.
find
(
'
FN
'
).
text
(),
// Successful callback
img
=
$vcard
.
find
(
'
BINVAL
'
).
text
(),
$vcard
=
$
(
iq
).
find
(
'
vCard
'
);
img_type
=
$vcard
.
find
(
'
TYPE
'
).
text
(),
var
fullname
=
$vcard
.
find
(
'
FN
'
).
text
(),
url
=
$vcard
.
find
(
'
URL
'
).
text
();
img
=
$vcard
.
find
(
'
BINVAL
'
).
text
(),
var
rosteritem
=
converse
.
roster
.
get
(
jid
);
img_type
=
$vcard
.
find
(
'
TYPE
'
).
text
(),
if
(
rosteritem
)
{
url
=
$vcard
.
find
(
'
URL
'
).
text
();
rosteritem
.
save
({
if
(
jid
)
{
'
fullname
'
:
fullname
||
jid
,
var
rosteritem
=
converse
.
roster
.
get
(
jid
);
'
image_type
'
:
img_type
,
if
(
rosteritem
)
{
'
image
'
:
img
,
rosteritem
.
save
({
'
url
'
:
url
,
'
fullname
'
:
fullname
||
jid
,
'
vcard_updated
'
:
converse
.
toISOString
(
new
Date
())
'
image_type
'
:
img_type
,
});
'
image
'
:
img
,
}
'
url
'
:
url
,
callback
(
jid
,
fullname
,
img
,
img_type
,
url
);
'
vcard_updated
'
:
converse
.
toISOString
(
new
Date
())
},
this
),
jid
,
errback
);
});
}
}
if
(
callback
)
{
callback
(
jid
,
fullname
,
img
,
img_type
,
url
);
}
},
this
),
jid
,
function
(
iq
)
{
// Error callback
var
rosteritem
=
converse
.
roster
.
get
(
jid
);
if
(
rosteritem
)
{
rosteritem
.
save
({
'
vcard_updated
'
:
converse
.
toISOString
(
new
Date
())
});
}
if
(
errback
)
{
errback
(
iq
);
}
});
};
};
this
.
RosterItems
=
Backbone
.
Collection
.
extend
({
this
.
RosterItems
=
Backbone
.
Collection
.
extend
({
...
@@ -2576,6 +2598,11 @@
...
@@ -2576,6 +2598,11 @@
var
view
=
new
converse
.
RosterItemView
({
model
:
item
});
var
view
=
new
converse
.
RosterItemView
({
model
:
item
});
this
.
rosteritemviews
[
item
.
id
]
=
view
;
this
.
rosteritemviews
[
item
.
id
]
=
view
;
this
.
render
(
item
);
this
.
render
(
item
);
if
(
!
item
.
get
(
'
vcard_updated
'
))
{
// This will update the vcard, which triggers a change
// request which will rerender the roster item.
converse
.
getVCard
(
item
.
get
(
'
jid
'
));
}
},
this
);
},
this
);
this
.
model
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
this
.
model
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
...
@@ -2653,7 +2680,7 @@
...
@@ -2653,7 +2680,7 @@
if
(
changed_presence
)
{
if
(
changed_presence
)
{
this
.
sortRoster
(
changed_presence
);
this
.
sortRoster
(
changed_presence
);
sorted
=
true
;
sorted
=
true
;
}
}
if
(
item
.
get
(
'
is_last
'
))
{
if
(
item
.
get
(
'
is_last
'
))
{
if
(
!
sorted
)
{
if
(
!
sorted
)
{
this
.
sortRoster
(
item
.
get
(
'
chat_status
'
));
this
.
sortRoster
(
item
.
get
(
'
chat_status
'
));
...
...
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