aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/clipboard.coffee29
-rw-r--r--lib/clipboard.js29
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;
- }
-};