From 2be8e15797522cfe26d9c952fe9ef9d29dd6e20a Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Fri, 13 Aug 2021 15:43:39 +0530 Subject: [PATCH 1/3] Allow copy paste of email from contact tab and footer without reversing --- app/views/shared/_footer.html.haml | 2 +- app/views/shopping_shared/tabs/_contact.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index aae6fdcebe..fbc4f3ae9f 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -53,7 +53,7 @@ %i.ofn-i_045-pintrest - if ContentConfig.footer_email.present? %p - %a{href: ContentConfig.footer_email.reverse, mailto: true, target: '_blank'} + %a{href: ContentConfig.footer_email, mailto: true, target: '_blank'} = t '.footer_contact_email' = render_markdown(ContentConfig.footer_links_md).html_safe diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index df487609bd..bc8ec6b4ca 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -32,8 +32,8 @@ %br - if current_distributor.email_address.present? %a{href: current_distributor.email_address.reverse, mailto: true} - %span.email - = current_distributor.email_address.reverse + %span + = current_distributor.email_address .small-12.large-4.columns - if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present? From d2dcfa5848c00e3f402c28dcec9443b53c313445 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Fri, 20 Aug 2021 13:15:44 +0530 Subject: [PATCH 2/3] Undo changes --- app/views/shared/_footer.html.haml | 2 +- app/views/shopping_shared/tabs/_contact.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index fbc4f3ae9f..aae6fdcebe 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -53,7 +53,7 @@ %i.ofn-i_045-pintrest - if ContentConfig.footer_email.present? %p - %a{href: ContentConfig.footer_email, mailto: true, target: '_blank'} + %a{href: ContentConfig.footer_email.reverse, mailto: true, target: '_blank'} = t '.footer_contact_email' = render_markdown(ContentConfig.footer_links_md).html_safe diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index bc8ec6b4ca..df487609bd 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -32,8 +32,8 @@ %br - if current_distributor.email_address.present? %a{href: current_distributor.email_address.reverse, mailto: true} - %span - = current_distributor.email_address + %span.email + = current_distributor.email_address.reverse .small-12.large-4.columns - if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present? From 92ecdb41634d466804c55f33c590e9fe77875b1a Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Fri, 20 Aug 2021 16:51:59 +0530 Subject: [PATCH 3/3] Add Angular directive to undo reverse of email --- .../darkswarm/directives/obfuscatedEmail.js.coffee | 7 +++++++ .../javascripts/templates/partials/contact.html.haml | 2 +- app/views/producers/_fat.html.haml | 2 +- app/views/shopping_shared/tabs/_contact.html.haml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/obfuscatedEmail.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/obfuscatedEmail.js.coffee b/app/assets/javascripts/darkswarm/directives/obfuscatedEmail.js.coffee new file mode 100644 index 0000000000..99c5315a83 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/obfuscatedEmail.js.coffee @@ -0,0 +1,7 @@ +angular.module('Darkswarm').directive "obfuscatedEmail", ()-> + restrict: 'C' + link: (scope, element, attrs)-> + element.on 'cut copy', (event)-> + event.preventDefault() + clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData + clipboardData.setData('text/plain', document.getSelection().toString().split('').reverse().join('')) diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index 9779dd0f3e..58c8c4a64d 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -5,7 +5,7 @@ %p{"ng-if" => "::enterprise.email_address"} %a{"ng-href" => "{{::enterprise.email_address | stripUrl}}", target: "_blank", mailto: true} - %span.email{"ng-bind" => "::enterprise.email_address | stripUrl"} + %span.obfuscatedEmail.email{"ng-bind" => "::enterprise.email_address | stripUrl"} %p{"ng-if" => "enterprise.website"} %a{"ng-href" => "http://{{::enterprise.website | stripUrl}}", target: "_blank", "ng-bind" => "::enterprise.website | stripUrl"} diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index 02c9bf6fef..fb2d1d8db7 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -40,7 +40,7 @@ %p.word-wrap{"ng-if" => "::producer.email_address"} %a{"ng-href" => "{{::producer.email_address | stripUrl}}", target: "_blank", mailto: true} - %span.email{"ng-bind" => "::producer.email_address | stripUrl"} + %span.obfuscatedEmail.email{"ng-bind" => "::producer.email_address | stripUrl"} %p.word-wrap{"ng-if" => "::producer.website"} %a{"ng-href" => "http://{{::producer.website | stripUrl}}", target: "_blank" } diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index df487609bd..cf8cf6da5f 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -32,7 +32,7 @@ %br - if current_distributor.email_address.present? %a{href: current_distributor.email_address.reverse, mailto: true} - %span.email + %span.obfuscatedEmail.email = current_distributor.email_address.reverse .small-12.large-4.columns