Get single recipient message composition working again

pull/749/head
lilia 11 years ago
parent c034ac8267
commit c2beda8e40

@ -86,11 +86,12 @@
</script> </script>
<script type='text/x-tmpl-mustache' id='new-message-form'> <script type='text/x-tmpl-mustache' id='new-message-form'>
<form class='send message'> <form class='send message'>
<input name='number' class='number'> <input type='text' name='number' class='number'>
<div class='send-message-area'> <div class='send-message-area'>
<div class='message-composer'> <div class='message-composer'>
<input class='send-message' rows='6' type='textarea'> <input name='message' class='send-message' rows='6' type='textarea'>
<div class='attachments'> Add Files </div> <div class='attachments'> Add Files </div>
<input type='submit'>
</div> </div>
<div class='extension-details'> <div class='extension-details'>
<ul> <ul>

@ -26,7 +26,7 @@ var Whisper = Whisper || {};
new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el); new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el);
}, },
events: { events: {
'submit #send': 'send' 'submit .send': 'send'
}, },
send: function(e) { send: function(e) {
@ -65,34 +65,36 @@ var Whisper = Whisper || {};
}); });
Whisper.NewConversationView = Backbone.View.extend({ Whisper.NewConversationView = Backbone.View.extend({
className: 'conversation',
initialize: function() { initialize: function() {
this.template = $('#new-message-form').html(); this.template = $('#new-message-form').html();
Mustache.parse(this.template); Mustache.parse(this.template);
this.render();
this.input = this.$el.find('input.number'); this.input = this.$el.find('input.number');
new Whisper.MessageRecipientInputView({el: this.input}); new Whisper.MessageRecipientInputView({el: this.input});
}, },
events: { events: {
'submit #send': 'send', 'submit .send': 'send',
'close': 'undelegateEvents' 'close': 'remove'
}, },
send: function(e) { send: function(e) {
e.preventDefault(); e.preventDefault();
var number = this.input.val(); var number = this.input.val();
if (textsecure.utils.verifyNumber(number)) { try {
var thread = Whisper.Threads.findOrCreateForRecipient(number); if (textsecure.utils.verifyNumber(number)) {
var send_input = this.$el.find('#send input'); var thread = Whisper.Threads.findOrCreateForRecipient(number);
thread.sendMessage(send_input.val()); var message_input = this.$el.find('input.send-message');
send_input.val(''); thread.sendMessage(message_input.val());
this.$el.find('form.message').remove(); this.remove();
this.$el.trigger('close'); }
new Whisper.ConversationView({model: thread}); } catch(ex) {}
}
}, },
render: function() { render: function() {
this.$el.html(Mustache.render(this.template)); this.$el.html(Mustache.render(this.template));
this.$el.show().insertAfter($('#gutter'));
return this; return this;
} }
}); });
@ -106,7 +108,7 @@ var Whisper = Whisper || {};
new_message: function(e) { new_message: function(e) {
e.preventDefault(); e.preventDefault();
$('.conversation').hide().trigger('close'); // detach any existing conversation views $('.conversation').hide().trigger('close'); // detach any existing conversation views
this.view = new Whisper.NewConversationView().render().$el.insertAfter($('#gutter')); this.view = new Whisper.NewConversationView().$el.insertAfter($('#gutter'));
//todo: less new //todo: less new
}, },

@ -0,0 +1,3 @@
.number.error {
background-color: #ffdddd;
}
Loading…
Cancel
Save