# copy-and-play

> A customizable, cross platform and easy to use text copying library.

Latest version **1.0.1** (published 2019-03-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install copy-and-play
pnpm add copy-and-play
yarn add copy-and-play
bun add copy-and-play
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-21 |
| First published | 2019-03-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ivanhoe-dev |
| Maintainers | ivanhoe-dev |
| Keywords | copy, clipboard, jquery |

## Links

- npm: https://www.npmjs.com/package/copy-and-play
- Repository: https://github.com/ivanhoe-dev/copy-and-play
- Homepage: https://github.com/ivanhoe-dev/copy-and-play#readme
- Issues: https://github.com/ivanhoe-dev/copy-and-play/issues
- npm.io page: https://npm.io/package/copy-and-play

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-03-21
- 1.0.0 — 2019-03-20

## README

## Copy And Play
A customizable, cross platform and easy to use text copying library.

### Demo
https://ivanhoe-dev.github.io/copy-and-play/

### Installation

npm install copy-and-play

### Usage
1. Import your Jquery and `cap.js` itself

        <script src="http://code.jquery.com/jquery-3.3.1.js"></script>
        <script type="text/javascript" src="cap.js"></script>
	
2. As `cap.js` contains ES6 code, if you want to support old browsers and IE, please import 'cap-es5.js' instead (e.g. [babel.js](https://github.com/babel/babel "babel.js")) before it

3. Call `cap.init()` if you want to apply settings globally

4. By calling `cap.copy(selector,[settings])`, a text will be copied.

|  Parameter Name |Type   |Description|
| ------------ | ------------ | ------------ |
| selector  | Jquery selector string   |the target to be copied|
|  settings (optional) |  JSON |the settings apply to this copy action locally|

### Settings JSON
An example of the setting JSON:

    {
	    	input: {
                visible: false,
                type: INPUT.TEXTAREA
            },
            successMessage: {
                enable: true,
                text: 'Copied to clipboard',
                position: null,
                timeout: 1000
            },
            lineBreak: true,
            onReady: null,
            onSuccess: null
	}

### Settings Details
|Option   |Type   |Description   |Default value
| ------------ | ------------ | ------------ |------------ |
|  input.visible | boolean  | The visibility of HTML input after copied  | false|
| input.type  |  enum  | The HTML input type: **<br></br-1>INPUT.TEXT  <br></br-1> INPUT.TEXTAREA**|INPUT.TEXTAREA |
|  successMessage.enable |  boolean | Enable of successfully copied message  |true|
| successMessage.text  | string   | Content of success message  |Copied to clipboard|
|  successMessage.position | Jquery selector string  | The position of the success message  |null|
| successMessage.timeout  | integer  |  The milliseconds of disappearing the successmessage <br></br-1>**-1** : not disappear |1000|
|  lineBreak |  boolean | enable of remaining line break of the  target text |true|
|  onReady |  function | callback before the copy action perform  |null|
|  onSuccess |  function | callback after the copy action perform   |null|

### Line Break
Line break can be remained and copied by the option `lineBreak`
However, as it only supports with a `textarea`, if you want to support copying line break, the library will set the input type as `textarea` by itself

### Browser Support
The library is compatible with Safari 11(IOS11), IE 11, Mozilla Firefox 65.0, Google chrome 72.0

### Author
[ivanhoe-dev](https://github.com/ivanhoe-dev "ivanhoe-dev") 
2019-03-20

---
_Source: https://npm.io/package/copy-and-play · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
