i18n KeyConflictView

Also refactor generic error view to make this simpler.

// FREEBIE
This commit is contained in:
lilia 2015-12-25 21:42:47 -08:00
parent ccdbfc3e12
commit d502f1bdee
3 changed files with 20 additions and 26 deletions

View file

@ -1,4 +1,10 @@
{
"outgoingKeyConflict": {
"message": "This contact's identity key has changed. Click to process and display."
},
"incomingKeyConflict": {
"message": "Received message with unknown identity key. Click to process and display."
},
"unsupportedAttachment": {
"message": "Unsupported attachment type. Click to save.",
"description": "Displayed for incoming unsupported attachment"

View file

@ -269,18 +269,6 @@
<div class='contacts'></div>
</div>
</script>
<script type='text/x-tmpl-mustache' id='incoming-key-conflict'>
<p>
Received message with unknown identity key.
Click to process and display.
</p>
</script>
<script type='text/x-tmpl-mustache' id='outgoing-key-conflict'>
<p>
This contact's identity key has changed.
Click to process and display.
</p>
</script>
<script type='text/x-tmpl-mustache' id='generic-error'>
<p>{{ message }}</p>
</script>

View file

@ -6,32 +6,32 @@
window.Whisper = window.Whisper || {};
var ErrorView = Backbone.View.extend({
var ErrorView = Whisper.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;
templateName: 'generic-error',
render_attributes: function() {
return this.model;
}
});
var KeyConflictView = ErrorView.extend({
className: 'key-conflict',
templateName: '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'
},
render_attributes: function() {
var errorMessage;
if (this.message.isIncoming()) {
errorMessage = 'incomingKeyConflict';
} else {
errorMessage = 'outgoingKeyConflict';
}
return { message: i18n(errorMessage) };
},
select: function() {
this.$el.trigger('select', {message: this.message});
},