Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valeriansaliou/jquery.clipboard
:scissors: jQuery Clipboard plugin (newest version) - Copy any text to the user's clipboard. Implements ZeroClipboard over the jQuery plugin layer.
https://github.com/valeriansaliou/jquery.clipboard
Last synced: 5 days ago
JSON representation
:scissors: jQuery Clipboard plugin (newest version) - Copy any text to the user's clipboard. Implements ZeroClipboard over the jQuery plugin layer.
- Host: GitHub
- URL: https://github.com/valeriansaliou/jquery.clipboard
- Owner: valeriansaliou
- License: mit
- Created: 2013-08-20T08:00:41.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-12-09T15:55:42.000Z (almost 4 years ago)
- Last Synced: 2024-08-03T12:03:32.238Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 70
- Watchers: 4
- Forks: 36
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
jQuery Clipboard
================jQuery Clipboard plugin: copy any text to the user's clipboard. Implements ZeroClipboard over the jQuery plugin layer.
## Usage
### 1. Before You Start
- Due to Flash restrictions, **jQuery Clipboard cannot be used on local domains** (localhost, .dev), you need to serve it from a genuine Internet domain (.com, .net or so)
- Please check that **you are using at least jQuery 1.7** - jQuery Clipboard won't work with versions below!### 2. Include Scripts
```html
```
### 3. Apply On An Element
```javascript
$(document).ready(function() {
var copy_sel = $('.code-block a.code-copy');// Disables other default handlers on click (avoid issues)
copy_sel.on('click', function(e) {
e.preventDefault();
});// Apply clipboard click event
copy_sel.clipboard({
path: '/path/to/flashes/jquery.clipboard.swf',copy: function() {
var this_sel = $(this);// Hide "Copy" and show "Copied, copy again?" message in link
this_sel.find('.code-copy-first').hide();
this_sel.find('.code-copy-done').show();// Return text in closest element (useful when you have multiple boxes that can be copied)
return this_sel.closest('.code-block').text();
}
});
});
```### 4. More Docs
More docs can be found on http://www.steamdev.com/zclip/
jQuery Clipboard is mostly based on jQuery.zClip, the plugin APIs remain almost the same.