Cable-Desktop/js/views/new_group_view.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

var Whisper = Whisper || {};
(function () {
'use strict';
Whisper.GroupRecipientsInputView = Backbone.View.extend({
initialize: function() {
this.$el.tagsinput({ tagClass: this.tagClass });
},
tagClass: function(item) {
try {
if (libphonenumber.util.verifyNumber(item)) {
return;
}
} catch(ex) {}
return 'error';
}
});
Whisper.NewGroupView = Backbone.View.extend({
2014-10-15 02:01:09 +02:00
className: 'conversation',
initialize: function() {
this.template = $('#new-group-form').html();
Mustache.parse(this.template);
this.render();
this.input = this.$el.find('input.number');
new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el);
},
events: {
2014-10-15 02:01:09 +02:00
'submit .send': 'send',
'close': 'remove'
},
send: function(e) {
e.preventDefault();
var numbers = this.$el.find('input.numbers').val().split(',');
var name = this.$el.find('input.name').val();
var thread = Whisper.Threads.createGroup(numbers, name);
2014-10-15 02:01:09 +02:00
thread.sendMessage(this.$el.find('input.send-message').val());
2014-10-15 06:35:40 +02:00
this.remove();
thread.trigger('render');
},
render: function() {
this.$el.prepend($(Mustache.render(this.template)));
2014-10-10 04:02:52 +02:00
Whisper.Layout.setContent(this.$el.show());
return this;
}
});
})();