diff options
| author | Phil Crosby | 2012-06-10 23:38:35 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-06-12 22:00:34 -0700 |
| commit | e8468e12f867cb71eb0d2b50c4904a1236b50e47 (patch) | |
| tree | c1002de1e819fec28306eff1e5f7375fdc013047 /lib | |
| parent | c7ce35423e3871dc121830f38de9cd79aebd704a (diff) | |
| download | vimium-e8468e12f867cb71eb0d2b50c4904a1236b50e47.tar.bz2 | |
port clipboard.js to coffeescript
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/clipboard.coffee | 29 | ||||
| -rw-r--r-- | lib/clipboard.js | 29 |
2 files changed, 29 insertions, 29 deletions
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; - } -}; |
