Start on panels

This commit is contained in:
Riley Shaw
2015-01-15 18:41:44 -10:00
committed by lilia
parent 02d0c58e5e
commit 2cbcb28ee3
13 changed files with 451 additions and 331 deletions

View File

@@ -19,6 +19,7 @@ var Whisper = Whisper || {};
(function () {
'use strict';
// list of conversations, showing user/group and last message sent
Whisper.ConversationListItemView = Backbone.View.extend({
tagName: 'div',
className: 'contact',
@@ -36,11 +37,28 @@ var Whisper = Whisper || {};
},
open: function(e) {
var modelId = this.model.id;
this.$el.addClass('selected');
if (!this.view) {
this.view = new Whisper.ConversationView({ model: this.model });
}
chrome.windows.create({
url: 'conversation.html#' + modelId,
type: 'panel',
focused: true,
width: 280,
height: 420
}, function (windowInfo) {
debugger;
extension.trigger('loadConversation', {
windowId: windowInfo.id,
conversationId: modelId
});
});
this.model.collection.trigger('selected', this.view);
},

View File

@@ -37,8 +37,8 @@
this.view = new Whisper.MessageListView({
collection: this.model.messageCollection
});
this.$el.find('.discussion-container').append(this.view.el);
$('#conversation-container').append(this.view.el);
//new ...({el: $(#conversation-container)})
this.model.fetchMessages({reset: true});
},
@@ -83,7 +83,20 @@
}
},
/*addAll: function() {
this.collection.each(this.addOne);
},
addOne: function(model) {
var view = new Whisper.Message({model: model});
view.render();
$(this.el).append(view.el);
model.bind('remove', view.remove);
},*/
render: function() {
//this.$el.empty();
//this.addAll();
this.delegateEvents();
this.view.delegateEvents();
this.view.scrollToBottom();

View File

@@ -22,9 +22,7 @@
initialize: function () {
this.gutter = $('#gutter');
this.contacts = $('#contacts');
this.resize();
window.addEventListener('resize', this.resize.bind(this));
this.conversations = new Whisper.ConversationCollection();
new Whisper.ConversationListView({
@@ -70,23 +68,8 @@
});
this.setContent(view.render().$el.show());
},
resize: function (e) {
var windowheight = window.innerHeight,
form = $('.send-message-area').outerHeight(),
gutter_offset = this.gutter.offset().top,
contacts_offset = this.contacts.offset().top;
if (window.innerWidth < 480) {
this.gutter.css('height', windowheight - gutter_offset - form);
this.contacts.css('height', windowheight - contacts_offset - form);
} else {
this.gutter.css('height', windowheight - gutter_offset);
this.contacts.css('height', windowheight - contacts_offset);
}
$('.discussion').css('height', windowheight - gutter_offset - form);
},
setContent: function (content) {
$(content).insertAfter(this.gutter);
this.resize();
}
});