Cable-Desktop/js/views/error_view.js
lilia f764445c86 Remove erroneous license file and headers
We only use GPLV3 around here.

// FREEBIE
2015-09-07 14:58:42 -07:00

60 lines
1.8 KiB
JavaScript

/*
* vim: ts=4:sw=4:expandtab
*/
(function () {
'use strict';
window.Whisper = window.Whisper || {};
var ErrorView = Backbone.View.extend({
className: 'error',
initialize: function() {
this.template = $('#generic-error').html();
Mustache.parse(this.template);
},
render: function() {
this.$el.html(Mustache.render(this.template, this.model));
return this;
}
});
var KeyConflictView = ErrorView.extend({
className: 'key-conflict',
initialize: function(options) {
this.message = options.message;
if (this.message.isIncoming()) {
this.template = $('#incoming-key-conflict').html();
} else if (this.message.isOutgoing()) {
this.template = $('#outgoing-key-conflict').html();
}
Mustache.parse(this.template);
},
events: {
'click': 'select'
},
select: function() {
this.$el.trigger('select', {message: this.message});
},
});
Whisper.MessageErrorView = Backbone.View.extend({
className: 'error',
initialize: function(options) {
if (this.model.name === 'IncomingIdentityKeyError' ||
this.model.name === 'OutgoingIdentityKeyError') {
this.view = new KeyConflictView({
model : this.model,
message : options.message
});
} else {
this.view = new ErrorView({ model: this.model });
}
this.$el.append(this.view.el);
this.view.render();
},
render: function() {
this.view.render();
return this;
}
});
})();