Skip to content

Commit

Permalink
Moved Composer crypto UI feedback to JS
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 27, 2014
1 parent 4e03ab8 commit 96317fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
32 changes: 16 additions & 16 deletions static/default/html/jsapi/compose/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,24 @@ Mailpile.Composer.Crypto.DetermineEncryption = function(mid, contact) {
Mailpile.Composer.Crypto.SignatureToggle = function(status, mid) {

if (status === 'sign') {
$('#compose-crypto-signature-' + mid).data('crypto_color', 'crypto-color-green');
$('#compose-crypto-signature-' + mid).attr('title', $('.compose-crypto-signature').data('crypto_title_signed'));
$('#compose-crypto-signature-' + mid).data('crypto_color', 'crypto-color-green');
$('#compose-crypto-signature-' + mid).attr('title', '{{_("This message will be verifiable to reicpients who have your encryption key. They will know it actually came from you :)")}}');
$('#compose-crypto-signature-' + mid).find('span.icon').removeClass('icon-signature-none').addClass('icon-signature-verified');
$('#compose-crypto-signature-' + mid).find('span.text').html($('.compose-crypto-signature').data('crypto_signed'));
$('#compose-crypto-signature-' + mid).find('span.text').html('{{_("Verifiable")}}');
$('#compose-crypto-signature-' + mid).removeClass('none').addClass('signed bounce');

} else if (status === 'none') {
$('#compose-crypto-signature-' + mid).data('crypto_color', 'crypto-color-gray');
$('#compose-crypto-signature-' + mid).attr('title', $('.compose-crypto-signature').data('crypto_title_not_signed'));
$('#compose-crypto-signature-' + mid).data('crypto_color', 'crypto-color-gray');
$('#compose-crypto-signature-' + mid).attr('title', '{{_("This message will not be verifiable, recipients will have no way of knowing it actually came from you.")}}');
$('#compose-crypto-signature-' + mid).find('span.icon').removeClass('icon-signature-verified').addClass('icon-signature-none');
$('#compose-crypto-signature-' + mid).find('span.text').html($('.compose-crypto-signature').data('crypto_not_signed'));
$('#compose-crypto-signature-' + mid).find('span.text').html('{{_("Unverifiable")}}');
$('#compose-crypto-signature-' + mid).removeClass('signed').addClass('none bounce');

} else {
$('#compose-crypto-signature-' + mid).data('crypto_color', 'crypto-color-red');
$('#compose-crypto-signature-' + mid).attr('title', $('.compose-crypto-signature').data('crypto_title_signed_error'));
$('#compose-crypto-signature-' + mid).attr('title', '{{_("Verification Error")}}');
$('#compose-crypto-signature-' + mid).find('span.icon').removeClass('icon-signature-none icon-signature-verified').addClass('icon-signature-error');
$('#compose-crypto-signature-' + mid).find('span.text').html($('.compose-crypto-signature').data('crypto_signed_error'));
$('#compose-crypto-signature-' + mid).find('span.text').html('{{_("Error accesing your encryption key")}}');
$('#compose-crypto-signature-' + mid).removeClass('none').addClass('error bounce');
}

Expand All @@ -141,30 +141,30 @@ Mailpile.Composer.Crypto.EncryptionToggle = function(status, mid) {

if (status == 'encrypt') {
$('#compose-crypto-encryption-' + mid).data('crypto_color', 'crypto-color-green');
$('#compose-crypto-encryption-' + mid).attr('title', $('.compose-crypto-encryption').data('crypto_title_encrypt'));
$('#compose-crypto-encryption-' + mid).attr('title', '{{_("This message and attachments will be encrypted. The recipients & subject (metadata) will not")}}');
$('#compose-crypto-encryption-' + mid).find('span.icon').removeClass('icon-lock-open').addClass('icon-lock-closed');
$('#compose-crypto-encryption-' + mid).find('span.text').html($('.compose-crypto-encryption').data('crypto_encrypt'));
$('#compose-crypto-encryption-' + mid).find('span.text').html('{{_("Encrypted")}}');
$('#compose-crypto-encryption-' + mid).removeClass('none error cannot').addClass('encrypted');

} else if (status === 'cannot') {
$('#compose-crypto-encryption-' + mid).data('crypto_color', 'crypto-color-orange');
$('#compose-crypto-encryption-' + mid).attr('title', $('.compose-crypto-encryption').data('crypto_title_cannot_encrypt'));
$('#compose-crypto-encryption-' + mid).attr('title', '{{_("This message cannot be encrypted because you do not have keys for one or more recipients")}}');
$('#compose-crypto-encryption-' + mid).find('span.icon').removeClass('icon-lock-closed').addClass('icon-lock-open');
$('#compose-crypto-encryption-' + mid).find('span.text').html($('.compose-crypto-encryption').data('crypto_cannot_encrypt'));
$('#compose-crypto-encryption-' + mid).find('span.text').html('{{_("Can Not Encrypt")}}');
$('#compose-crypto-encryption-' + mid).removeClass('none encrypted error').addClass('cannot');

} else if (status === 'none' || status == '') {
$('#compose-crypto-encryption-' + mid).data('crypto_color', 'crypto-color-gray');
$('#compose-crypto-encryption-' + mid).attr('title', $('.compose-crypto-encryption').data('crypto_title_none'));
$('#compose-crypto-encryption-' + mid).attr('title', '{{_("This message and metadata will not be encrypted")}}');
$('#compose-crypto-encryption-' + mid).find('span.icon').removeClass('icon-lock-closed').addClass('icon-lock-open');
$('#compose-crypto-encryption-' + mid).find('span.text').html($('.compose-crypto-encryption').data('crypto_none'));
$('#compose-crypto-encryption-' + mid).find('span.text').html('{{_("None")}}');
$('#compose-crypto-encryption-' + mid).removeClass('encrypted cannot error').addClass('none');

} else {
$('#compose-crypto-encryption-' + mid).data('crypto_color', 'crypto-color-red');
$('#compose-crypto-encryption-' + mid).attr('title', $('.compose-crypto-encryption').data('crypto_title_encrypt_error'));
$('#compose-crypto-encryption-' + mid).attr('title', '{{_("There was an error prepping this message for encryption")}}');
$('#compose-crypto-encryption-' + mid).find('span.icon').removeClass('icon-lock-open icon-lock-closed').addClass('icon-lock-error');
$('#compose-crypto-encryption-' + mid).find('span.text').html($('.compose-crypto-encryption').data('crypto_cannot_encrypt'));
$('#compose-crypto-encryption-' + mid).find('span.text').html('{{_("Error Encrypting")}}');
$('#compose-crypto-encryption-' + mid).removeClass('encrypted cannot none').addClass('error');
}

Expand Down
23 changes: 7 additions & 16 deletions static/default/html/partials/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,17 @@
</div>
<div class="compose-options clearfix" data-mid="{{mid}}">
<div class="compose-options-crypto">
<div id="compose-crypto-encryption-{{mid}}" class="compose-crypto-encryption none"
data-mid="{{mid}}"
data-crypto_none="{{_("None")}}"
data-crypto_encrypt="{{_("Encrypted")}}"
data-crypto_cannot_encrypt="{{_("Can't Encrypt")}}"
data-crypto_encrypt_error="{{_("Error Encrypting")}}"
data-crypto_title_none="{{_("This message and metadata will not be encrypted")}}"
data-crypto_title_encrypt="{{_("This message and attachments will be encrypted. The recipients & subject (metadata) will not")}}"
data-crypto_title_cannot_encrypt="{{_("This message cannot be encrypted because you do not have keys for one or more recipients")}}"
data-crypto_title_encrypt_error="{{_("There was an error prepping this message for encryption")}}">
<div id="compose-crypto-encryption-{{mid}}" class="compose-crypto-encryption none" data-mid="{{mid}}">
<span class="icon icon-lock-open"></span><span class="text hide">{{_("None")}}</span>
</div>
<div id="compose-crypto-signature-{{mid}}" class="compose-crypto-signature none"
data-mid="{{mid}}"
data-crypto_signed="{{_("Verifiable")}}"
data-crypto_not_signed="{{_("Unverifiable")}}"
data-crypto_signed_error="{{_("Verification Error")}}"
data-crypto_title_signed="{{_("This message will be verifiable with your encryption key. Recipients who have your key will know it actually came from you :)")}}"
data-crypto_title_not_signed="{{_("This message will not be verifiable, recipients will have no way of knowing it actually came from you.")}}"
data-crypto_title_signed_error="{{_("Error accesing your key")}}">
data-crypto_signed=""
data-crypto_not_signed=""
data-crypto_signed_error=""
data-crypto_title_signed=""
data-crypto_title_not_signed=""
data-crypto_title_signed_error="">
<span class="icon icon-signature-none"></span><span class="text hide">{{_("Unsigned")}}</span>
</div>
</div>
Expand Down

0 comments on commit 96317fd

Please sign in to comment.