Skip to content

Commit

Permalink
Added copy button to translated text (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-hub committed Apr 13, 2021
1 parent be7366a commit cf0ba05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions assets/css/translation.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ html[dir='rtl'] textarea {
top: 3px;
}

.copyButton {
background-color: rgba(0, 0, 0, 0);
padding: 0 3px;
top: 3px;
}

.clearButton:hover,
.clearButton:focus {
background-color: #eee;
Expand All @@ -131,6 +137,14 @@ html[dir='rtl'] .clearButton {
left: 18px;
}

html[dir='ltr'] .copyButton {
right: 18px;
}

html[dir='rtl'] .copyButton {
left: 18px;
}

html[dir='ltr'] .otherTranslationOptions > *:not(*:last-child),
html[dir='rtl'] .otherTranslationOptions > *:not(*:first-child) {
margin-right: 5px;
Expand Down
5 changes: 5 additions & 0 deletions assets/js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ if(modeEnabled('translation')) {
synchronizeTextareaHeights();
});

$('#copyText').click(function () {
$('#translatedText').select();
document.execCommand('copy');
});

$(window).resize(synchronizeTextareaHeights);

$('#originalText').blur(function () {
Expand Down
3 changes: 3 additions & 0 deletions html/index.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@
<div class="col-12 col-md-6">
<textarea class="form-control bg-light" id="translatedText" rows="15" spellcheck="false" aria-label="Translated Text"
readonly></textarea>
<button id="copyText" class="btn copyButton position-absolute" aria-label="Copy Text">
<i class="fa fa-clipboard"></i>
</button>
</div>
</div>
<div class="row mt-2">
Expand Down

0 comments on commit cf0ba05

Please sign in to comment.