2014-08-11 08:34:29 +02:00
|
|
|
var Whisper = Whisper || {};
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Whisper.GroupRecipientsInputView = Backbone.View.extend({
|
|
|
|
initialize: function() {
|
|
|
|
this.$el.tagsinput({ tagClass: this.tagClass });
|
|
|
|
},
|
|
|
|
|
|
|
|
tagClass: function(item) {
|
|
|
|
try {
|
2014-10-12 02:19:16 +02:00
|
|
|
if (libphonenumber.util.verifyNumber(item)) {
|
2014-08-11 08:34:29 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch(ex) {}
|
|
|
|
return 'error';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Whisper.NewGroupView = Backbone.View.extend({
|
2014-10-15 02:01:09 +02:00
|
|
|
className: 'conversation',
|
2014-08-11 08:34:29 +02:00
|
|
|
initialize: function() {
|
|
|
|
this.template = $('#new-group-form').html();
|
|
|
|
Mustache.parse(this.template);
|
|
|
|
this.render();
|
2014-10-15 00:24:50 +02:00
|
|
|
this.input = this.$el.find('input.number');
|
2014-08-11 08:34:29 +02:00
|
|
|
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'
|
2014-08-11 08:34:29 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
send: function(e) {
|
2014-10-15 00:24:50 +02:00
|
|
|
e.preventDefault();
|
2014-08-11 08:34:29 +02:00
|
|
|
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');
|
2014-08-11 08:34:29 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
this.$el.prepend($(Mustache.render(this.template)));
|
2014-10-10 04:02:52 +02:00
|
|
|
Whisper.Layout.setContent(this.$el.show());
|
2014-08-11 08:34:29 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
})();
|