diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Cakefile | 4 | ||||
| -rw-r--r-- | lib/clipboard.coffee | 29 | ||||
| -rw-r--r-- | lib/clipboard.js | 29 | 
4 files changed, 32 insertions, 31 deletions
| @@ -4,3 +4,4 @@ tests/completion_test.js  tests/test_helper.js  tests/utils_test.js  background_scripts/settings.js +lib/clipboard.js @@ -2,11 +2,11 @@ fs = require "fs"  {spawn, exec} = require "child_process"  task "build", "compile all coffeescript files to javascript", -> -  coffee = spawn "coffee", ["tests", "background_scripts"] +  coffee = spawn "coffee", ["tests", "background_scripts", "lib"]    coffee.stdout.on "data", (data) -> console.log data.toString().trim()  task "autobuild", "continually rebuild coffeescript files using coffee --watch", -> -  coffee = spawn "coffee", ["-cw", "tests", "background_scripts"] +  coffee = spawn "coffee", ["-cw", "tests", "background_scripts", "lib"]    coffee.stdout.on "data", (data) -> console.log data.toString().trim()  task "test", "run all unit tests", -> diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee new file mode 100644 index 00000000..2b28df70 --- /dev/null +++ b/lib/clipboard.coffee @@ -0,0 +1,29 @@ +Clipboard = +  _createTextArea: -> +    textArea = document.createElement("textarea") +    textArea.style.position = "absolute" +    textArea.style.left = "-100%" +    textArea + +  # http://groups.google.com/group/chromium-extensions/browse_thread/thread/49027e7f3b04f68/f6ab2457dee5bf55 +  copy: (data) -> +    textArea = @_createTextArea() +    textArea.value = data + +    document.body.appendChild(textArea) +    textArea.select() +    document.execCommand("Copy") +    document.body.removeChild(textArea) + +  paste: -> +    textArea = @._createTextArea() +    document.body.appendChild(textArea) +    textArea.focus() +    document.execCommand("Paste") +    value = textArea.value +    document.body.removeChild(textArea) +    value + + +root = exports ? window +root.Clipboard = Clipboard diff --git a/lib/clipboard.js b/lib/clipboard.js deleted file mode 100644 index b6d3940e..00000000 --- a/lib/clipboard.js +++ /dev/null @@ -1,29 +0,0 @@ -var Clipboard = { -  _createTextArea: function() { -    var textArea = document.createElement("textarea"); -    textArea.style.position = "absolute"; -    textArea.style.left = "-100%"; -    return textArea; -  }, - -  // http://groups.google.com/group/chromium-extensions/browse_thread/thread/49027e7f3b04f68/f6ab2457dee5bf55 -  copy: function(data) { -    var textArea = this._createTextArea(); -    textArea.value = data; - -    document.body.appendChild(textArea); -    textArea.select(); -    document.execCommand("Copy"); -    document.body.removeChild(textArea); -  }, - -  paste: function() { -    var textArea = this._createTextArea(); -    document.body.appendChild(textArea); -    textArea.focus(); -    document.execCommand("Paste"); -    var rv = textArea.value; -    document.body.removeChild(textArea); -    return rv; -  } -}; | 
