this content was originally posted here.

clipboard copy js

for copying things to the clipboard, like the click to copy.

Basic Usage

Include the script

<script src="js/clipboard.min.js"></script>

add a field to copy to the clipboard

<input id="clipme" value="https://github.com/zenorocha/clipboard.js.git">

add a button or link to copy it and bind it to the id clipme

<a class='btn btn-primary' data-clipboard-target="#clipme">Copy to Clipboard</a>

Well this is a bit of a fail it seems to be targeting the script src from above... hmm.

Ah its cos i forgot to start the plugin... doh!

Also have to add this selector to the elements that are going top be running the copy and paste

new Clipboard('.btn');

Ok it works now, it should highlight the text in the field above when you click the button, it copied to my clipboard ok.

Seems like a bit of effort to get working. But its not too bad once you remember to:

  1. add the main script clipboard.min.js
  2. add a field or element to copy with correct #id
  3. add the button with the data binding data-clipboard-target="#id"
  4. initialise the script and target the button new Clipboard('#id');

thats the basic usage, for more detailed usage go to the official site

Links

clipboardjs.com

clipboard.js

clipboard.min.js

clipboard.js-master.zip

Demo

database file: /home/kruxor/Dropbox/ssl.kruxor.com/root/kruxor.com/db/db.db
comments_dbfile: /home/kruxor/Dropbox/ssl.kruxor.com/root/kruxor.com/db/comments.db ($db_comments)
views_dbfile: /home/kruxor/Dropbox/ssl.kruxor.com/root/kruxor.com/db/views.db
$dbfood_file: /home/kruxor/Dropbox/ssl.kruxor.com/root/kruxor.com/db/food.db
db_linx: /home/kruxor/Dropbox/ssl.kruxor.com/root/kruxor.com/linx/db/db.db
Classes Loaded:
class/answers.class.php
class/code.class.php
class/comments.class.php
class/content.class.php
class/core.class.php
class/crud.class.php
class/crumbs.class.php
class/featured.class.php
class/food.class.php
class/functions.class.php
class/images.class.php
class/import.class.php
class/links.class.php
class/questions.class.php
class/template.class.php
class/tv.class.php
class/user.class.php
class/utilities.class.php
class/views.class.php
class/widget.class.php
Class Extend Loaded: class/extends/expenses.extend.php
Class Extend Loaded: class/extends/gary_cummins_timeline.extend.php
Class Extend Loaded: class/extends/moo.extend.php
Class Extend Loaded: class/extends/osrs_item_data.extend.php
Class Extend Loaded: class/extends/osrs_slayer.extend.php
Class Extend Loaded: class/extends/osrs_slayer_monsters.extend.php
Class Extend Loaded: class/extends/searches.extend.php
Core Database Connected: expenses.db
expenses add_to_menu:
Class Extend Auto Initialized as: expenses
Core Database Connected: gary_cummins_timeline.db
gary_cummins_timeline add_to_menu:
Class Extend Auto Initialized as: gary_cummins_timeline
Core Database Connected: moo.db
moo add_to_menu:
Class Extend Auto Initialized as: moo
Core Database Connected: osrs_item_data.db
osrs_item_data add_to_menu:
Class Extend Auto Initialized as: osrs_item_data
Core Database Connected: osrs_slayer.db
osrs_slayer add_to_menu:
Class Extend Auto Initialized as: osrs_slayer
Core Database Connected: osrs_slayer_monsters.db
osrs_slayer_monsters add_to_menu:
Class Extend Auto Initialized as: osrs_slayer_monsters
Core Database Connected: searches.db
searches add_to_menu:
Class Extend Auto Initialized as: searches
$user_logged_in:
user access level:
pages:
$p1:view
$p2:code
$p3:ADhnj
$p4:clipboard-copy-js
$p5:
$p6:
$p:/view/code/ADhnj/clipboard-copy-js/
Using Template: view-code.html