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
21fd082c
Commit
21fd082c
authored
Aug 04, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Only position groups once all of them have been fetched.
updates #83
parent
2ff7061e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
Makefile
Makefile
+1
-1
converse.js
converse.js
+43
-2
No files found.
Makefile
View file @
21fd082c
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
BOWER
?=
node_modules/.bin/bower
BOWER
?=
node_modules/.bin/bower
BUILDDIR
=
./docs
BUILDDIR
=
./docs
PAPER
=
PAPER
=
PHANTOMJS
?=
node_modules/.bin/
phantomjs
PHANTOMJS
?=
phantomjs
SPHINXBUILD
=
sphinx-build
SPHINXBUILD
=
sphinx-build
SPHINXOPTS
=
SPHINXOPTS
=
...
...
converse.js
View file @
21fd082c
...
@@ -3361,7 +3361,10 @@
...
@@ -3361,7 +3361,10 @@
this
.
model
.
on
(
"
add
"
,
this
.
onGroupAdd
,
this
);
this
.
model
.
on
(
"
add
"
,
this
.
onGroupAdd
,
this
);
this
.
model
.
on
(
"
reset
"
,
this
.
reset
,
this
);
this
.
model
.
on
(
"
reset
"
,
this
.
reset
,
this
);
this
.
render
();
this
.
render
();
this
.
model
.
fetch
({
add
:
true
});
this
.
model
.
fetch
({
silent
:
true
,
success
:
$
.
proxy
(
this
.
positionFetchedGroups
,
this
)
});
converse
.
roster
.
fetch
({
add
:
true
});
converse
.
roster
.
fetch
({
add
:
true
});
},
},
...
@@ -3443,6 +3446,30 @@
...
@@ -3443,6 +3446,30 @@
return
this
;
return
this
;
},
},
positionFetchedGroups
:
function
(
model
,
resp
,
options
)
{
/* Instead of throwing an add event for each group
* fetched, we wait until they're all fetched and then
* we position them.
* Works around the problem of positionGroup not
* working when all groups besides the one being
* positioned aren't already in inserted into the
* roster DOM element.
*/
model
.
sort
();
model
.
each
(
$
.
proxy
(
function
(
group
,
idx
)
{
var
view
=
this
.
get
(
group
.
get
(
'
name
'
))
if
(
!
view
)
{
view
=
new
converse
.
RosterGroupView
({
model
:
group
});
this
.
add
(
group
.
get
(
'
name
'
),
view
.
render
());
}
if
(
idx
===
0
)
{
this
.
$el
.
append
(
view
.
$el
);
}
else
{
this
.
appendGroup
(
view
);
}
},
this
));
},
positionGroup
:
function
(
view
)
{
positionGroup
:
function
(
view
)
{
/* Place the group's DOM element in the correct alphabetical
/* Place the group's DOM element in the correct alphabetical
* position amongst the other groups in the roster.
* position amongst the other groups in the roster.
...
@@ -3451,10 +3478,24 @@
...
@@ -3451,10 +3478,24 @@
if
(
index
===
0
)
{
if
(
index
===
0
)
{
this
.
$el
.
prepend
(
view
.
$el
);
this
.
$el
.
prepend
(
view
.
$el
);
}
else
if
(
index
==
(
this
.
model
.
length
-
1
))
{
}
else
if
(
index
==
(
this
.
model
.
length
-
1
))
{
this
.
$
(
'
.roster-group
'
).
last
().
siblings
(
'
dd
'
).
last
().
after
(
view
.
$el
);
this
.
appendGroup
(
view
);
}
else
{
}
else
{
$
(
this
.
$
(
'
.roster-group
'
).
eq
(
index
)).
before
(
view
.
$el
);
$
(
this
.
$
(
'
.roster-group
'
).
eq
(
index
)).
before
(
view
.
$el
);
}
}
return
this
;
},
appendGroup
:
function
(
view
)
{
/* Add the group at the bottom of the roster
*/
var
$last
=
this
.
$
(
'
.roster-group
'
).
last
();
var
$siblings
=
$last
.
siblings
(
'
dd
'
);
if
(
$siblings
.
length
>
0
)
{
$siblings
.
last
().
after
(
view
.
$el
);
}
else
{
$last
.
after
(
view
.
$el
);
}
return
this
;
},
},
getGroup
:
function
(
name
)
{
getGroup
:
function
(
name
)
{
...
...
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