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
7f753040
Commit
7f753040
authored
Jun 21, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move roster-related models/collections to core
parent
888cd8c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
58 deletions
+61
-58
src/converse-controlbox.js
src/converse-controlbox.js
+1
-1
src/converse-core.js
src/converse-core.js
+18
-0
src/converse-rosterview.js
src/converse-rosterview.js
+42
-57
No files found.
src/converse-controlbox.js
View file @
7f753040
...
...
@@ -10,7 +10,7 @@
define
(
"
converse-controlbox
"
,
[
"
converse-core
"
,
"
converse-api
"
,
// TODO:
remove the next two dependencies
// TODO:
The next two dependencies can be made optional
"
converse-rosterview
"
,
"
converse-chatview
"
],
factory
);
...
...
src/converse-core.js
View file @
7f753040
...
...
@@ -250,6 +250,7 @@
// Translation machinery
// ---------------------
var
__
=
utils
.
__
.
bind
(
this
);
var
DESC_GROUP_TOGGLE
=
__
(
'
Click to hide these contacts
'
);
// Default configuration values
// ----------------------------
...
...
@@ -1178,6 +1179,23 @@
});
this
.
RosterGroup
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attributes
,
options
)
{
this
.
set
(
_
.
extend
({
description
:
DESC_GROUP_TOGGLE
,
state
:
converse
.
OPENED
},
attributes
));
// Collection of contacts belonging to this group.
this
.
contacts
=
new
converse
.
RosterContacts
();
}
});
this
.
RosterGroups
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
RosterGroup
,
});
this
.
Message
=
Backbone
.
Model
.
extend
({
defaults
:
function
(){
return
{
...
...
src/converse-rosterview.js
View file @
7f753040
...
...
@@ -18,6 +18,25 @@
_
=
converse_api
.
env
.
_
,
__
=
utils
.
__
.
bind
(
converse
);
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
LABEL_CONTACTS
=
__
(
'
Contacts
'
);
var
LABEL_GROUPS
=
__
(
'
Groups
'
);
var
HEADER_CURRENT_CONTACTS
=
__
(
'
My contacts
'
);
var
HEADER_PENDING_CONTACTS
=
__
(
'
Pending contacts
'
);
var
HEADER_REQUESTING_CONTACTS
=
__
(
'
Contact requests
'
);
var
HEADER_UNGROUPED
=
__
(
'
Ungrouped
'
);
var
HEADER_WEIGHTS
=
{};
HEADER_WEIGHTS
[
HEADER_CURRENT_CONTACTS
]
=
0
;
HEADER_WEIGHTS
[
HEADER_UNGROUPED
]
=
1
;
HEADER_WEIGHTS
[
HEADER_REQUESTING_CONTACTS
]
=
2
;
HEADER_WEIGHTS
[
HEADER_PENDING_CONTACTS
]
=
3
;
converse_api
.
plugins
.
add
(
'
rosterview
'
,
{
...
...
@@ -32,6 +51,29 @@
this
.
rosterview
.
registerRosterXHandler
();
this
.
rosterview
.
registerPresenceHandler
();
this
.
_super
.
afterReconnected
.
apply
(
this
,
arguments
);
},
RosterGroups
:
{
comparator
:
function
(
a
,
b
)
{
/* Groups are sorted alphabetically, ignoring case.
* However, Ungrouped, Requesting Contacts and Pending Contacts
* appear last and in that order.
*/
a
=
a
.
get
(
'
name
'
);
b
=
b
.
get
(
'
name
'
);
var
special_groups
=
_
.
keys
(
HEADER_WEIGHTS
);
var
a_is_special
=
_
.
contains
(
special_groups
,
a
);
var
b_is_special
=
_
.
contains
(
special_groups
,
b
);
if
(
!
a_is_special
&&
!
b_is_special
)
{
return
a
.
toLowerCase
()
<
b
.
toLowerCase
()
?
-
1
:
(
a
.
toLowerCase
()
>
b
.
toLowerCase
()
?
1
:
0
);
}
else
if
(
a_is_special
&&
b_is_special
)
{
return
HEADER_WEIGHTS
[
a
]
<
HEADER_WEIGHTS
[
b
]
?
-
1
:
(
HEADER_WEIGHTS
[
a
]
>
HEADER_WEIGHTS
[
b
]
?
1
:
0
);
}
else
if
(
!
a_is_special
&&
b_is_special
)
{
return
(
b
===
HEADER_CURRENT_CONTACTS
)
?
1
:
-
1
;
}
else
if
(
a_is_special
&&
!
b_is_special
)
{
return
(
a
===
HEADER_CURRENT_CONTACTS
)
?
-
1
:
1
;
}
}
}
},
...
...
@@ -46,27 +88,6 @@
show_toolbar
:
true
,
});
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
DESC_GROUP_TOGGLE
=
__
(
'
Click to hide these contacts
'
);
var
LABEL_CONTACTS
=
__
(
'
Contacts
'
);
var
LABEL_GROUPS
=
__
(
'
Groups
'
);
var
HEADER_CURRENT_CONTACTS
=
__
(
'
My contacts
'
);
var
HEADER_PENDING_CONTACTS
=
__
(
'
Pending contacts
'
);
var
HEADER_REQUESTING_CONTACTS
=
__
(
'
Contact requests
'
);
var
HEADER_UNGROUPED
=
__
(
'
Ungrouped
'
);
var
HEADER_WEIGHTS
=
{};
HEADER_WEIGHTS
[
HEADER_CURRENT_CONTACTS
]
=
0
;
HEADER_WEIGHTS
[
HEADER_UNGROUPED
]
=
1
;
HEADER_WEIGHTS
[
HEADER_REQUESTING_CONTACTS
]
=
2
;
HEADER_WEIGHTS
[
HEADER_PENDING_CONTACTS
]
=
3
;
converse
.
RosterFilter
=
Backbone
.
Model
.
extend
({
initialize
:
function
()
{
this
.
set
({
...
...
@@ -692,18 +713,6 @@
});
converse
.
RosterGroup
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attributes
,
options
)
{
this
.
set
(
_
.
extend
({
description
:
DESC_GROUP_TOGGLE
,
state
:
converse
.
OPENED
},
attributes
));
// Collection of contacts belonging to this group.
this
.
contacts
=
new
converse
.
RosterContacts
();
}
});
converse
.
RosterGroupView
=
Backbone
.
Overview
.
extend
({
tagName
:
'
dt
'
,
className
:
'
roster-group
'
,
...
...
@@ -879,30 +888,6 @@
}
}
});
converse
.
RosterGroups
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
RosterGroup
,
comparator
:
function
(
a
,
b
)
{
/* Groups are sorted alphabetically, ignoring case.
* However, Ungrouped, Requesting Contacts and Pending Contacts
* appear last and in that order. */
a
=
a
.
get
(
'
name
'
);
b
=
b
.
get
(
'
name
'
);
var
special_groups
=
_
.
keys
(
HEADER_WEIGHTS
);
var
a_is_special
=
_
.
contains
(
special_groups
,
a
);
var
b_is_special
=
_
.
contains
(
special_groups
,
b
);
if
(
!
a_is_special
&&
!
b_is_special
)
{
return
a
.
toLowerCase
()
<
b
.
toLowerCase
()
?
-
1
:
(
a
.
toLowerCase
()
>
b
.
toLowerCase
()
?
1
:
0
);
}
else
if
(
a_is_special
&&
b_is_special
)
{
return
HEADER_WEIGHTS
[
a
]
<
HEADER_WEIGHTS
[
b
]
?
-
1
:
(
HEADER_WEIGHTS
[
a
]
>
HEADER_WEIGHTS
[
b
]
?
1
:
0
);
}
else
if
(
!
a_is_special
&&
b_is_special
)
{
return
(
b
===
HEADER_CURRENT_CONTACTS
)
?
1
:
-
1
;
}
else
if
(
a_is_special
&&
!
b_is_special
)
{
return
(
a
===
HEADER_CURRENT_CONTACTS
)
?
-
1
:
1
;
}
}
});
}
});
}));
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