Get single recipient message composition working again
This commit is contained in:
parent
c034ac8267
commit
c2beda8e40
3 changed files with 21 additions and 15 deletions
|
@ -86,11 +86,12 @@
|
|||
</script>
|
||||
<script type='text/x-tmpl-mustache' id='new-message-form'>
|
||||
<form class='send message'>
|
||||
<input name='number' class='number'>
|
||||
<input type='text' name='number' class='number'>
|
||||
<div class='send-message-area'>
|
||||
<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>
|
||||
<input type='submit'>
|
||||
</div>
|
||||
<div class='extension-details'>
|
||||
<ul>
|
||||
|
|
|
@ -26,7 +26,7 @@ var Whisper = Whisper || {};
|
|||
new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el);
|
||||
},
|
||||
events: {
|
||||
'submit #send': 'send'
|
||||
'submit .send': 'send'
|
||||
},
|
||||
|
||||
send: function(e) {
|
||||
|
@ -65,34 +65,36 @@ var Whisper = Whisper || {};
|
|||
});
|
||||
|
||||
Whisper.NewConversationView = Backbone.View.extend({
|
||||
className: 'conversation',
|
||||
initialize: function() {
|
||||
this.template = $('#new-message-form').html();
|
||||
Mustache.parse(this.template);
|
||||
this.render();
|
||||
this.input = this.$el.find('input.number');
|
||||
new Whisper.MessageRecipientInputView({el: this.input});
|
||||
},
|
||||
|
||||
events: {
|
||||
'submit #send': 'send',
|
||||
'close': 'undelegateEvents'
|
||||
'submit .send': 'send',
|
||||
'close': 'remove'
|
||||
},
|
||||
|
||||
send: function(e) {
|
||||
e.preventDefault();
|
||||
var number = this.input.val();
|
||||
if (textsecure.utils.verifyNumber(number)) {
|
||||
var thread = Whisper.Threads.findOrCreateForRecipient(number);
|
||||
var send_input = this.$el.find('#send input');
|
||||
thread.sendMessage(send_input.val());
|
||||
send_input.val('');
|
||||
this.$el.find('form.message').remove();
|
||||
this.$el.trigger('close');
|
||||
new Whisper.ConversationView({model: thread});
|
||||
}
|
||||
try {
|
||||
if (textsecure.utils.verifyNumber(number)) {
|
||||
var thread = Whisper.Threads.findOrCreateForRecipient(number);
|
||||
var message_input = this.$el.find('input.send-message');
|
||||
thread.sendMessage(message_input.val());
|
||||
this.remove();
|
||||
}
|
||||
} catch(ex) {}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(Mustache.render(this.template));
|
||||
this.$el.show().insertAfter($('#gutter'));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
@ -106,7 +108,7 @@ var Whisper = Whisper || {};
|
|||
new_message: function(e) {
|
||||
e.preventDefault();
|
||||
$('.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
|
||||
},
|
||||
|
||||
|
|
3
stylesheets/index.css
Normal file
3
stylesheets/index.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
.number.error {
|
||||
background-color: #ffdddd;
|
||||
}
|
Loading…
Reference in a new issue