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