2015-09-07 23:53:43 +02:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2015-01-19 01:16:24 +01:00
|
|
|
*/
|
2014-07-22 20:55:26 +02:00
|
|
|
(function () {
|
2015-03-06 00:44:53 +01:00
|
|
|
'use strict';
|
|
|
|
window.Whisper = window.Whisper || {};
|
2014-07-22 20:55:26 +02:00
|
|
|
|
2015-03-06 00:44:53 +01:00
|
|
|
Whisper.ConversationListView = Whisper.ListView.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
itemView: Whisper.ConversationListItemView,
|
2016-03-25 18:39:36 +01:00
|
|
|
sort: function(conversation) {
|
2015-09-14 22:30:21 +02:00
|
|
|
var $el = this.$('.' + conversation.cid);
|
|
|
|
if ($el && $el.length > 0) {
|
2016-03-25 18:39:36 +01:00
|
|
|
var index = getInboxCollection().indexOf(conversation);
|
2016-07-19 03:05:49 +02:00
|
|
|
if (index === this.$el.index($el)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-28 00:29:53 +02:00
|
|
|
if (index === 0) {
|
2016-03-25 18:39:36 +01:00
|
|
|
this.$el.prepend($el);
|
2016-03-28 00:29:53 +02:00
|
|
|
} else if (index === this.collection.length - 1) {
|
|
|
|
this.$el.append($el);
|
|
|
|
} else {
|
|
|
|
$el.insertBefore(this.$('.conversation-list-item')[index+1]);
|
2015-09-15 01:28:27 +02:00
|
|
|
}
|
2015-09-14 22:30:21 +02:00
|
|
|
}
|
2015-03-06 00:44:53 +01:00
|
|
|
}
|
|
|
|
});
|
2014-07-22 20:55:26 +02:00
|
|
|
})();
|