mirror of https://github.com/vector-im/riot-web
i18n and change message depending on success of copy
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
269f1f33e3
commit
b10b0e573d
|
@ -73,12 +73,16 @@ module.exports = React.createClass({
|
||||||
textArea.value = text;
|
textArea.value = text;
|
||||||
document.body.appendChild(textArea);
|
document.body.appendChild(textArea);
|
||||||
textArea.select();
|
textArea.select();
|
||||||
|
|
||||||
|
let successful;
|
||||||
try {
|
try {
|
||||||
const successful = document.execCommand('copy');
|
successful = document.execCommand('copy');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Unable to copy');
|
console.log('Unable to copy');
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.removeChild(textArea);
|
document.body.removeChild(textArea);
|
||||||
|
return successful;
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
@ -119,7 +123,7 @@ module.exports = React.createClass({
|
||||||
for (let i = 0; i < buttons.length; i++) {
|
for (let i = 0; i < buttons.length; i++) {
|
||||||
buttons[i].onclick = (e) => {
|
buttons[i].onclick = (e) => {
|
||||||
const copyCode = buttons[i].parentNode.getElementsByTagName("code")[0];
|
const copyCode = buttons[i].parentNode.getElementsByTagName("code")[0];
|
||||||
this.copyToClipboard(copyCode.textContent);
|
const successful = this.copyToClipboard(copyCode.textContent);
|
||||||
|
|
||||||
const GenericTextContextMenu = sdk.getComponent('context_menus.GenericTextContextMenu');
|
const GenericTextContextMenu = sdk.getComponent('context_menus.GenericTextContextMenu');
|
||||||
const buttonRect = e.target.getBoundingClientRect();
|
const buttonRect = e.target.getBoundingClientRect();
|
||||||
|
@ -131,7 +135,7 @@ module.exports = React.createClass({
|
||||||
chevronOffset: 10,
|
chevronOffset: 10,
|
||||||
left: x,
|
left: x,
|
||||||
top: y,
|
top: y,
|
||||||
message: "Copied!",
|
message: successful ? _t('Copied!') : _t('Failed to copy'),
|
||||||
});
|
});
|
||||||
e.target.onmouseout = close;
|
e.target.onmouseout = close;
|
||||||
};
|
};
|
||||||
|
|
|
@ -620,6 +620,8 @@
|
||||||
"Encrypt room": "Encrypt room",
|
"Encrypt room": "Encrypt room",
|
||||||
"There are no visible files in this room": "There are no visible files in this room",
|
"There are no visible files in this room": "There are no visible files in this room",
|
||||||
"Room": "Room",
|
"Room": "Room",
|
||||||
|
"Copied!": "Copied!",
|
||||||
|
"Failed to copy": "Failed to copy",
|
||||||
"Connectivity to the server has been lost.": "Connectivity to the server has been lost.",
|
"Connectivity to the server has been lost.": "Connectivity to the server has been lost.",
|
||||||
"Sent messages will be stored until your connection has returned.": "Sent messages will be stored until your connection has returned.",
|
"Sent messages will be stored until your connection has returned.": "Sent messages will be stored until your connection has returned.",
|
||||||
"Auto-complete": "Auto-complete",
|
"Auto-complete": "Auto-complete",
|
||||||
|
|
Loading…
Reference in New Issue