Bugfix. Don't call Jed's translate method
before converse.initialize has been called. Otherwise we won't get translations. Updates #669
This commit is contained in:
parent
71381e2f22
commit
01e10a9b24
@ -18,26 +18,6 @@
|
||||
_ = 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_REQUESTING_CONTACTS] = 0;
|
||||
HEADER_WEIGHTS[HEADER_CURRENT_CONTACTS] = 1;
|
||||
HEADER_WEIGHTS[HEADER_UNGROUPED] = 2;
|
||||
HEADER_WEIGHTS[HEADER_PENDING_CONTACTS] = 3;
|
||||
|
||||
converse_api.plugins.add('rosterview', {
|
||||
|
||||
overrides: {
|
||||
@ -46,32 +26,16 @@
|
||||
// relevant objects or classes.
|
||||
//
|
||||
// New functions which don't exist yet can also be added.
|
||||
|
||||
afterReconnected: function () {
|
||||
this.rosterview.registerRosterXHandler();
|
||||
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_REQUESTING_CONTACTS) ? 1 : -1;
|
||||
} else if (a_is_special && !b_is_special) {
|
||||
return (a === HEADER_REQUESTING_CONTACTS) ? -1 : 1;
|
||||
}
|
||||
comparator: function () {
|
||||
// RosterGroupsComparator only gets set later (once i18n is
|
||||
// set up), so we need to wrap it in this nameless function.
|
||||
return converse.RosterGroupsComparator.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -87,6 +51,48 @@
|
||||
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 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_REQUESTING_CONTACTS] = 0;
|
||||
HEADER_WEIGHTS[HEADER_CURRENT_CONTACTS] = 1;
|
||||
HEADER_WEIGHTS[HEADER_UNGROUPED] = 2;
|
||||
HEADER_WEIGHTS[HEADER_PENDING_CONTACTS] = 3;
|
||||
|
||||
converse.RosterGroupsComparator = 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_REQUESTING_CONTACTS) ? 1 : -1;
|
||||
} else if (a_is_special && !b_is_special) {
|
||||
return (a === HEADER_REQUESTING_CONTACTS) ? -1 : 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
converse.RosterFilter = Backbone.Model.extend({
|
||||
initialize: function () {
|
||||
this.set({
|
||||
|
Loading…
Reference in New Issue
Block a user