Fix Copy so it still works after query results have been copied. Fixes #2637

This commit is contained in:
Surinder Kumar 2017-08-31 14:50:22 +01:00 committed by Dave Page
parent 47cf874460
commit c4393a7795

View File

@ -43,14 +43,14 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
textArea.select(); textArea.select();
document.addEventListener('copy', function(e) { var copyTextToClipboardHandler = function(e) {
/* Remove oncopy event listener from document as we add listener for /* Remove oncopy event listener from document as we add listener for
* oncopy event on each copy operation. * oncopy event on each copy operation.
* Also we don't want this listener to be persistent; Otherwise it'll get * Also we don't want this listener to be persistent; Otherwise it'll get
* called for each copy operation performed on any input/textarea from * called for each copy operation performed on any input/textarea from
* this document. * this document.
*/ */
document.removeEventListener('copy', copyTextToClipboardHandler);
var clipboardData = e.clipboardData || window.clipboardData; var clipboardData = e.clipboardData || window.clipboardData;
if (clipboardData) { if (clipboardData) {
@ -58,7 +58,9 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
// We want our data, not data from any selection, to be written to the clipboard // We want our data, not data from any selection, to be written to the clipboard
e.preventDefault(); e.preventDefault();
} }
}); };
document.addEventListener('copy', copyTextToClipboardHandler);
try { try {
// just perform copy on empty textarea so that copy event will be // just perform copy on empty textarea so that copy event will be
@ -74,4 +76,4 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
}, },
}; };
return clipboard; return clipboard;
}); });