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
31
| var extend = require('./extend');
| var noop = require('./noop');
| exports = function(text, cb) {
| cb = cb || noop;
| var el = document.createElement('textarea');
| var body = document.body;
| extend(el.style, {
| fontSize: '12pt',
| border: '0',
| padding: '0',
| margin: '0',
| position: 'absolute',
| left: '-9999px'
| });
| el.value = text;
| body.appendChild(el);
|
| el.setAttribute('readonly', '');
| el.select();
| el.setSelectionRange(0, text.length);
| try {
| document.execCommand('copy');
| cb();
| } catch (e) {
| cb(e);
| } finally {
| body.removeChild(el);
| }
| };
|
| module.exports = exports;
|
|