Explorar o código

Blur the linkAddress field so it doesn't get focused when user reenters a page

dvemula %!s(int64=13) %!d(string=hai) anos
pai
achega
3747792dac
Modificáronse 2 ficheiros con 7 adicións e 2 borrados
  1. 6 1
      copylinkaddress.js
  2. 1 1
      manifest.json

+ 6 - 1
copylinkaddress.js

@@ -6,6 +6,7 @@ linkAddress.css({position: 'absolute', left:'-9999em'});
 function clearLinkAddress() {
     if (linkAddress.val()) {
         linkAddress.val(null);
+//        linkAddress.blur();
         console.log("Cleared linkAddress");
         window.getSelection().removeAllRanges();
     }
@@ -21,6 +22,7 @@ $(function() {
                 console.log("Nothing is selected. Copyl kicks in.");
                 linkAddress.val($(this).prop('href'));
                 linkAddress.select();
+                linkAddress.blur();
                 console.log("linkAddress: " + linkAddress.val());
             }
             console.log("Current Selection: " + window.getSelection().toString());
@@ -32,5 +34,8 @@ $(function() {
     });
 
     // Clear linkAddress when user closes or moves away from the page
-    window.onbeforeunload = clearLinkAddress();
+    window.onbeforeunload = function() {
+        console.log("Leaving page.");
+        clearLinkAddress();
+    }
 });

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "Copy Link Address",
-    "version": "0.3",
+    "version": "0.3.1",
     "description": "Copy link address without right-clicking. Just hover the link and hit Ctrl-C / Cmd-C!",
     "content_scripts": [
         {