Commit 691c4846 authored by JC Brand's avatar JC Brand

Hide the roster filter by default. Updates #949

- Also, use a virtual-dom view for rendering the roster filter.
parent cfd5dad9
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
### Bugfixes ### Bugfixes
- #800 Could not register successfully in ejabberd 17.01 - #800 Could not register successfully in ejabberd 17.01
- #949 Don't flash the roster contacts filter (i.e. hide by default)
- Don't require `auto_login` to be `true` when using the API to log in. - Don't require `auto_login` to be `true` when using the API to log in.
- Moment locale wasn't being set to the value passed via the `i18n` option. - Moment locale wasn't being set to the value passed via the `i18n` option.
- Refetch the roster from the server after reconnection. - Refetch the roster from the server after reconnection.
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
}, },
}); });
_converse.RosterFilterView = Backbone.View.extend({ _converse.RosterFilterView = Backbone.VDOMView.extend({
tagName: 'span', tagName: 'span',
events: { events: {
"keydown .roster-filter": "liveFilter", "keydown .roster-filter": "liveFilter",
...@@ -145,8 +145,8 @@ ...@@ -145,8 +145,8 @@
this.model.on('change:filter_text', this.renderClearButton, this); this.model.on('change:filter_text', this.renderClearButton, this);
}, },
render () { renderHTML () {
this.el.innerHTML = tpl_roster_filter( return tpl_roster_filter(
_.extend(this.model.toJSON(), { _.extend(this.model.toJSON(), {
placeholder: __('Filter'), placeholder: __('Filter'),
label_contacts: LABEL_CONTACTS, label_contacts: LABEL_CONTACTS,
...@@ -161,8 +161,10 @@ ...@@ -161,8 +161,10 @@
label_xa: __('Extended Away'), label_xa: __('Extended Away'),
label_offline: __('Offline') label_offline: __('Offline')
})); }));
},
afterRender () {
this.renderClearButton(); this.renderClearButton();
return this.$el;
}, },
renderClearButton () { renderClearButton () {
...@@ -231,13 +233,14 @@ ...@@ -231,13 +233,14 @@
}, },
show () { show () {
if (this.$el.is(':visible')) { return this; } if (utils.isVisible(this.el)) { return this; }
this.$el.show(); this.el.classList.add('fade-in');
this.el.classList.remove('hidden');
return this; return this;
}, },
hide () { hide () {
if (!this.$el.is(':visible')) { return this; } if (!utils.isVisible(this.el)) { return this; }
if (this.el.querySelector('.roster-filter').value.length > 0) { if (this.el.querySelector('.roster-filter').value.length > 0) {
// Don't hide if user is currently filtering. // Don't hide if user is currently filtering.
return; return;
...@@ -246,7 +249,7 @@ ...@@ -246,7 +249,7 @@
'filter_text': '', 'filter_text': '',
'chat_state': '' 'chat_state': ''
}); });
this.$el.hide(); this.el.classList.add('hidden');
return this; return this;
}, },
...@@ -279,7 +282,9 @@ ...@@ -279,7 +282,9 @@
render () { render () {
this.renderRoster(); this.renderRoster();
this.$el.html(this.filter_view.render()); this.el.innerHTML = "";
this.el.appendChild(this.filter_view.render().el);
if (!_converse.allow_contact_requests) { if (!_converse.allow_contact_requests) {
// XXX: if we ever support live editing of config then // XXX: if we ever support live editing of config then
// we'll need to be able to remove this class on the fly. // we'll need to be able to remove this class on the fly.
...@@ -327,7 +332,7 @@ ...@@ -327,7 +332,7 @@
}, _converse.animate ? 100 : 0), }, _converse.animate ? 100 : 0),
showHideFilter () { showHideFilter () {
if (!this.$el.is(':visible')) { if (!utils.isVisible(this.el)) {
return; return;
} }
if (_converse.roster.length >= 10) { if (_converse.roster.length >= 10) {
......
<span class="hidden">
<form class="pure-form roster-filter-form input-button-group"> <form class="pure-form roster-filter-form input-button-group">
<input value="{{{o.filter_text}}}" <input value="{{{o.filter_text}}}"
class="roster-filter roster-filter-{{{o.filter_type}}}" class="roster-filter roster-filter-{{{o.filter_type}}}"
...@@ -28,3 +29,4 @@ ...@@ -28,3 +29,4 @@
value="state">{{{o.label_state}}}</option> value="state">{{{o.label_state}}}</option>
</select> </select>
</form> </form>
</span>
...@@ -531,5 +531,11 @@ ...@@ -531,5 +531,11 @@
model.set(attributes); model.set(attributes);
} }
} }
u.isVisible = function (el) {
// XXX: Taken from jQuery's "visible" implementation
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
};
return u; return u;
})); }));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment