Cable-Desktop/js/views/new_group_view.js
lilia fd3a72d435 Destroy all globals
Well, not *all* globals..
2014-11-24 19:25:03 -08:00

48 lines
1.3 KiB
JavaScript

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({
className: 'conversation',
initialize: function() {
this.template = $('#new-group-form').html();
Mustache.parse(this.template);
this.$el.html($(Mustache.render(this.template)));
this.input = this.$el.find('input.number');
new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el);
},
events: {
'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 view = this;
this.collection.createGroup(numbers, name).then(function(convo){
convo.sendMessage(view.$el.find('input.send-message').val());
view.remove();
convo.trigger('render');
});
}
});
})();