0.01
No commit activity in last 3 years
No release in over 3 years
Wrapper for jQuery - zClip (zeroclipboard). Adds easy copy to clipboard functionality to your Rails 3.x app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.0.17
 Project Readme

⚠️ Author Warning ⚠️

I added this wrapper to give access to the zclip Jquery plugin. Nevertheless I can not recommend Zclip. A better solution is to use the zeroclipboard-rails.

Zclip::Rails

Adds easy copytoclipboard functionality to your html-elements this is done by including the Jquery zClip libary to Rails 3.x.

Installation

Add this line to your application's Gemfile:

gem 'zclip-rails'

And then execute:

$ bundle

Add this line to your application.js:

//= require zclip

Usage

Add an element (button, input, div, span etc.) somewhere in your .erb template e.g.:

<button type="button" id="copy-some-txt">example</button>

Add this in some required js file of your app:

$('#copy-some-txt').zclip({
    copy: "this is the text to copy"
});

Supply custom callback functions

$('#copy-some-txt').zclip({
    copy: "this is the text to copy",
    beforeCopy: function() {
      alert("I am going to copy some text to your clipboard");
    },
    afterCopy: function() {
      alert("done");
    }
});

Settings

Settings

Variable
Default Value
Available Values
copy * null any string, or any javascript expression or function that returns a string
afterCopy null specify a function to call after text is copied.

(your afterCopy function will overwrite the default alert box.)
beforeCopy null specify a function to call before text is copied.
clickAfter true true
false
setHandCursor true true
false
setCSSEffects true true
false
* required

Notes

Proper CSS effects

zClip is a flash overlay, so it must provide the target element with "hover" and "active" classes to simulate native :hover and :active states. Be sure to write your CSS as follows for best results:

a:hover, a.hover {...}
a:active, a.active {...}

$('a.copy').zclip('show'); // enable zClip on the selected element

$('a.copy').zclip('hide'); // hide zClip on the selected element

$('a.copy').zclip('remove'); // remove zClip from the selected element

Requirements

  • jquery
  • Rails 3.x

Browsersupport

The Zero Clipboard Library has been tested on the following browsers / platforms:

Browser Windows XP SP3 Windows Vista Mac OS X Leopard
Internet Exploder 7.0 7.0 -
Firefox 3.0 3.0 3.0
Safari - - 3.0
Google Chrome 1.0 1.0 -

Adobe Flash Flash Player versions 9 and 10 are supported.

TODO

  • Write a gem tests

Credits

  • Thanks to Joseph Huckaby for writing the zeroclipboard libary.

  • Thanks to steamdev.com for writing the jQuery wrapper.

  • Thanks to all the contributers to this Project.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request