Skip to content

Commit 0f5d286

Browse files
Aayush-hubTinoDidriksen
authored andcommitted
Added copy button to translated text (#394)
1 parent be7366a commit 0f5d286

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

assets/css/translation.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ html[dir='rtl'] textarea {
117117
top: 3px;
118118
}
119119

120+
.copyButton {
121+
background-color: rgba(0, 0, 0, 0);
122+
padding: 0 3px;
123+
top: 3px;
124+
}
125+
120126
.clearButton:hover,
121127
.clearButton:focus {
122128
background-color: #eee;
@@ -131,6 +137,14 @@ html[dir='rtl'] .clearButton {
131137
left: 18px;
132138
}
133139

140+
html[dir='ltr'] .copyButton {
141+
right: 18px;
142+
}
143+
144+
html[dir='rtl'] .copyButton {
145+
left: 18px;
146+
}
147+
134148
html[dir='ltr'] .otherTranslationOptions > *:not(*:last-child),
135149
html[dir='rtl'] .otherTranslationOptions > *:not(*:first-child) {
136150
margin-right: 5px;

assets/js/translator.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ if(modeEnabled('translation')) {
5252
synchronizeTextareaHeights();
5353
});
5454

55+
$('#copyText').click(function () {
56+
$('#translatedText').select();
57+
document.execCommand('copy');
58+
});
59+
5560
$(window).resize(synchronizeTextareaHeights);
5661

5762
$('#originalText').blur(function () {

html/index.html.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@
199199
<div class="col-12 col-md-6">
200200
<textarea class="form-control bg-light" id="translatedText" rows="15" spellcheck="false" aria-label="Translated Text"
201201
readonly></textarea>
202+
<button id="copyText" class="btn copyButton position-absolute" aria-label="Copy Text">
203+
<i class="fa fa-clipboard"></i>
204+
</button>
202205
</div>
203206
</div>
204207
<div class="row mt-2">

0 commit comments

Comments
 (0)