aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-04-01 12:09:40 -0700
committerAlex Yatskov <alex@foosoft.net>2017-04-01 12:09:40 -0700
commit681470db67fc4fa706e2d29ee5beb54859fe5567 (patch)
tree9e818516591765b38fbcb304479886b8b6c6f04d /ext/fg/js
parentf7e47d1dbd1f9a7d42af2cecc4de8d078b062a89 (diff)
parent4eb3e2f06cd83ef0721557f8559fc0a6d70ad4f5 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/display-frame.js22
-rw-r--r--ext/fg/js/driver.js4
2 files changed, 26 insertions, 0 deletions
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js
index 59032d0c..9fd09e74 100644
--- a/ext/fg/js/display-frame.js
+++ b/ext/fg/js/display-frame.js
@@ -51,6 +51,10 @@ window.displayFrame = new class extends Display {
window.parent.postMessage('popupClose', '*');
}
+ selectionCopy() {
+ window.parent.postMessage('selectionCopy', '*');
+ }
+
showOrphaned() {
$('#content').hide();
$('#orphan').show();
@@ -77,4 +81,22 @@ window.displayFrame = new class extends Display {
handler(params);
}
}
+
+ onKeyDown(e) {
+ const handlers = {
+ 67: /* c */ () => {
+ if (e.ctrlKey && window.getSelection().toString() === '') {
+ this.selectionCopy();
+ return true;
+ }
+ }
+ };
+
+ const handler = handlers[e.keyCode];
+ if (handler && handler()) {
+ e.preventDefault();
+ } else {
+ super.onKeyDown(e);
+ }
+ }
};
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 5191f18d..d4cb1532 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -106,6 +106,10 @@ window.driver = new class {
const handlers = {
popupClose: () => {
this.searchClear();
+ },
+
+ selectionCopy: () => {
+ document.execCommand('copy');
}
};