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
1299a1d4
Commit
1299a1d4
authored
Aug 11, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for filtering by group. update #212
parent
03cf27af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
17 deletions
+55
-17
converse.js
converse.js
+51
-17
src/templates/roster.html
src/templates/roster.html
+4
-0
No files found.
converse.js
View file @
1299a1d4
...
@@ -292,6 +292,9 @@
...
@@ -292,6 +292,9 @@
var
HEADER_REQUESTING_CONTACTS
=
__
(
'
Contact requests
'
);
var
HEADER_REQUESTING_CONTACTS
=
__
(
'
Contact requests
'
);
var
HEADER_UNGROUPED
=
__
(
'
Ungrouped
'
);
var
HEADER_UNGROUPED
=
__
(
'
Ungrouped
'
);
var
LABEL_CONTACTS
=
__
(
'
Contacts
'
);
var
LABEL_GROUPS
=
__
(
'
Groups
'
);
var
HEADER_WEIGHTS
=
{};
var
HEADER_WEIGHTS
=
{};
HEADER_WEIGHTS
[
HEADER_CURRENT_CONTACTS
]
=
0
;
HEADER_WEIGHTS
[
HEADER_CURRENT_CONTACTS
]
=
0
;
HEADER_WEIGHTS
[
HEADER_UNGROUPED
]
=
1
;
HEADER_WEIGHTS
[
HEADER_UNGROUPED
]
=
1
;
...
@@ -1496,7 +1499,7 @@
...
@@ -1496,7 +1499,7 @@
label_away
:
__
(
'
Away
'
),
label_away
:
__
(
'
Away
'
),
label_offline
:
__
(
'
Offline
'
)
label_offline
:
__
(
'
Offline
'
)
});
});
this
.
$tabs
.
append
(
converse
.
templates
.
contacts_tab
({
label_contacts
:
__
(
'
Contacts
'
)
}));
this
.
$tabs
.
append
(
converse
.
templates
.
contacts_tab
({
label_contacts
:
LABEL_CONTACTS
}));
if
(
converse
.
xhr_user_search
)
{
if
(
converse
.
xhr_user_search
)
{
markup
=
converse
.
templates
.
search_contact
({
markup
=
converse
.
templates
.
search_contact
({
label_contact_name
:
__
(
'
Contact name
'
),
label_contact_name
:
__
(
'
Contact name
'
),
...
@@ -3282,6 +3285,10 @@
...
@@ -3282,6 +3285,10 @@
return
view
;
return
view
;
},
},
hide
:
function
()
{
this
.
$el
.
nextUntil
(
'
dt
'
).
addBack
().
hide
();
},
filter
:
function
(
q
)
{
filter
:
function
(
q
)
{
/* Filter the group's contacts based on the query "q".
/* Filter the group's contacts based on the query "q".
* The query is matched against the contact's full name.
* The query is matched against the contact's full name.
...
@@ -3305,7 +3312,7 @@
...
@@ -3305,7 +3312,7 @@
q
=
q
.
toLowerCase
();
q
=
q
.
toLowerCase
();
matches
=
this
.
model
.
contacts
.
filter
(
predicate
);
matches
=
this
.
model
.
contacts
.
filter
(
predicate
);
if
(
matches
.
length
===
this
.
model
.
contacts
.
length
)
{
// hide the whole group
if
(
matches
.
length
===
this
.
model
.
contacts
.
length
)
{
// hide the whole group
this
.
$el
.
nextUntil
(
'
dt
'
).
addBack
().
hide
();
this
.
hide
();
}
else
{
}
else
{
_
.
each
(
matches
,
$
.
proxy
(
function
(
item
)
{
_
.
each
(
matches
,
$
.
proxy
(
function
(
item
)
{
this
.
get
(
item
.
get
(
'
id
'
)).
$el
.
hide
();
this
.
get
(
item
.
get
(
'
id
'
)).
$el
.
hide
();
...
@@ -3334,7 +3341,10 @@
...
@@ -3334,7 +3341,10 @@
}
else
{
}
else
{
$el
.
removeClass
(
"
icon-closed
"
).
addClass
(
"
icon-opened
"
);
$el
.
removeClass
(
"
icon-closed
"
).
addClass
(
"
icon-opened
"
);
this
.
model
.
save
({
state
:
OPENED
});
this
.
model
.
save
({
state
:
OPENED
});
this
.
filter
(
converse
.
rosterview
.
$
(
'
.roster-filter
'
).
val
());
this
.
filter
(
converse
.
rosterview
.
$
(
'
.roster-filter
'
).
val
(),
converse
.
rosterview
.
$
(
'
.filter-type
'
).
val
()
);
}
}
},
},
...
@@ -3395,7 +3405,8 @@
...
@@ -3395,7 +3405,8 @@
events
:
{
events
:
{
"
keydown .roster-filter
"
:
"
liveFilter
"
,
"
keydown .roster-filter
"
:
"
liveFilter
"
,
"
click .onX
"
:
"
clearFilter
"
,
"
click .onX
"
:
"
clearFilter
"
,
"
mousemove .x
"
:
"
togglePointer
"
"
mousemove .x
"
:
"
togglePointer
"
,
"
change .filter-type
"
:
"
changeFilterType
"
},
},
initialize
:
function
()
{
initialize
:
function
()
{
...
@@ -3418,13 +3429,22 @@
...
@@ -3418,13 +3429,22 @@
render
:
function
()
{
render
:
function
()
{
this
.
$el
.
html
(
converse
.
templates
.
roster
({
this
.
$el
.
html
(
converse
.
templates
.
roster
({
placeholder
:
__
(
'
Type to filter contacts
'
)
placeholder
:
__
(
'
Type to filter
'
),
label_contacts
:
LABEL_CONTACTS
,
label_groups
:
LABEL_GROUPS
}));
}));
this
.
$filter
=
this
.
$
(
'
.roster-filter
'
);
this
.
$roster
=
this
.
$
(
'
.roster-contacts
'
);
return
this
;
return
this
;
},
},
changeFilterType
:
function
(
ev
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
this
.
clearFilter
();
this
.
filter
(
this
.
$
(
'
.roster-filter
'
).
val
(),
ev
.
target
.
value
);
},
tog
:
function
(
v
)
{
tog
:
function
(
v
)
{
return
v
?
'
addClass
'
:
'
removeClass
'
;
return
v
?
'
addClass
'
:
'
removeClass
'
;
},
},
...
@@ -3435,32 +3455,46 @@
...
@@ -3435,32 +3455,46 @@
$
(
el
)[
this
.
tog
(
el
.
offsetWidth
-
18
<
ev
.
clientX
-
el
.
getBoundingClientRect
().
left
)](
'
onX
'
);
$
(
el
)[
this
.
tog
(
el
.
offsetWidth
-
18
<
ev
.
clientX
-
el
.
getBoundingClientRect
().
left
)](
'
onX
'
);
},
},
filter
:
function
(
q
)
{
filter
:
function
(
query
,
type
)
{
_
.
each
(
this
.
getAll
(),
function
(
view
)
{
var
matches
;
view
.
filter
(
q
);
query
=
query
.
toLowerCase
();
});
if
(
type
===
'
groups
'
)
{
matches
=
_
.
filter
(
this
.
getAll
(),
function
(
view
)
{
return
view
.
model
.
get
(
'
name
'
).
toLowerCase
().
indexOf
(
query
)
===
-
1
;
});
_
.
each
(
matches
,
function
(
view
)
{
view
.
hide
();
});
}
else
{
_
.
each
(
this
.
getAll
(),
function
(
view
)
{
view
.
filter
(
query
,
type
);
});
}
},
},
liveFilter
:
_
.
debounce
(
function
(
ev
)
{
liveFilter
:
_
.
debounce
(
function
(
ev
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
var
q
=
ev
.
target
.
value
;
var
q
=
ev
.
target
.
value
;
var
t
=
this
.
$
(
'
.filter-type
'
).
val
();
$
(
ev
.
target
)[
this
.
tog
(
q
)](
'
x
'
);
$
(
ev
.
target
)[
this
.
tog
(
q
)](
'
x
'
);
this
.
filter
(
q
);
this
.
filter
(
q
,
t
);
},
500
),
},
500
),
clearFilter
:
function
(
ev
)
{
clearFilter
:
function
(
ev
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
if
(
ev
&&
ev
.
preventDefault
)
{
$
(
ev
.
target
).
removeClass
(
'
x onX
'
).
val
(
''
);
ev
.
preventDefault
();
$
(
ev
.
target
).
removeClass
(
'
x onX
'
).
val
(
''
);
}
this
.
filter
(
''
);
this
.
filter
(
''
);
},
},
showHideFilter
:
function
()
{
showHideFilter
:
function
()
{
var
visible
=
this
.
$filter
.
is
(
'
:visible
'
);
var
$filter
=
this
.
$
(
'
.roster-filter
'
);
if
(
visible
&&
this
.
$filter
.
val
().
length
>
0
)
{
var
visible
=
$filter
.
is
(
'
:visible
'
);
if
(
visible
&&
$filter
.
val
().
length
>
0
)
{
// Don't hide if user is currently filtering.
// Don't hide if user is currently filtering.
return
;
return
;
}
}
var
$filter
=
this
.
$
(
'
.roster-filter
'
);
if
(
this
.
$
(
'
.roster-contacts
'
).
hasScrollBar
())
{
if
(
this
.
$
(
'
.roster-contacts
'
).
hasScrollBar
())
{
if
(
!
visible
)
{
if
(
!
visible
)
{
$filter
.
show
();
$filter
.
show
();
...
...
src/templates/roster.html
View file @
1299a1d4
<input
class=
"roster-filter"
placeholder=
"{{placeholder}}"
>
<input
class=
"roster-filter"
placeholder=
"{{placeholder}}"
>
<select
class=
"filter-type"
>
<option
value=
"contacts"
>
{{label_contacts}}
</option>
<option
value=
"groups"
>
{{label_groups}}
</option>
</select>
<dl
class=
"roster-contacts"
style=
"display: block;"
>
<dl
class=
"roster-contacts"
style=
"display: block;"
>
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