blob: 1d378e767ceb3c6ad402bf7c189c54f1f7a6968c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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 ?= {})
root.Clipboard = Clipboard
extend window, root unless exports?
|