i18n KeyConflictView
Also refactor generic error view to make this simpler. // FREEBIE
This commit is contained in:
parent
ccdbfc3e12
commit
d502f1bdee
3 changed files with 20 additions and 26 deletions
|
@ -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": {
|
"unsupportedAttachment": {
|
||||||
"message": "Unsupported attachment type. Click to save.",
|
"message": "Unsupported attachment type. Click to save.",
|
||||||
"description": "Displayed for incoming unsupported attachment"
|
"description": "Displayed for incoming unsupported attachment"
|
||||||
|
|
|
@ -269,18 +269,6 @@
|
||||||
<div class='contacts'></div>
|
<div class='contacts'></div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</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'>
|
<script type='text/x-tmpl-mustache' id='generic-error'>
|
||||||
<p>{{ message }}</p>
|
<p>{{ message }}</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -6,32 +6,32 @@
|
||||||
|
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
var ErrorView = Backbone.View.extend({
|
var ErrorView = Whisper.View.extend({
|
||||||
className: 'error',
|
className: 'error',
|
||||||
initialize: function() {
|
templateName: 'generic-error',
|
||||||
this.template = $('#generic-error').html();
|
render_attributes: function() {
|
||||||
Mustache.parse(this.template);
|
return this.model;
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
this.$el.html(Mustache.render(this.template, this.model));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var KeyConflictView = ErrorView.extend({
|
var KeyConflictView = ErrorView.extend({
|
||||||
className: 'key-conflict',
|
className: 'key-conflict',
|
||||||
|
templateName: 'key-conflict',
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.message = options.message;
|
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: {
|
events: {
|
||||||
'click': 'select'
|
'click': 'select'
|
||||||
},
|
},
|
||||||
|
render_attributes: function() {
|
||||||
|
var errorMessage;
|
||||||
|
if (this.message.isIncoming()) {
|
||||||
|
errorMessage = 'incomingKeyConflict';
|
||||||
|
} else {
|
||||||
|
errorMessage = 'outgoingKeyConflict';
|
||||||
|
}
|
||||||
|
return { message: i18n(errorMessage) };
|
||||||
|
},
|
||||||
select: function() {
|
select: function() {
|
||||||
this.$el.trigger('select', {message: this.message});
|
this.$el.trigger('select', {message: this.message});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue