<commit_before># clipboard-rails
[![Gem Version](https://badge.fury.io/rb/clipboard-rails.svg)](http://badge.fury.io/rb/clipboard-rails)

clipboard-rails gem is the integration of clipboard.js javascript library for your Rails 4 and Rails 5 applications.

clipboard.js is a modern approach to copy text to clipboard No Flash. No dependencies. Just 2kb
source: https://github.com/zenorocha/clipboard.js

Ruby gems url: https://rubygems.org/gems/clipboard-rails

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'clipboard-rails'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install clipboard-rails

Now you need to edit your `app/assets/javascripts/application.js` file and add the following line:
``` javascript
//= require clipboard
```

## Usage

Here is the example working code to test with your Rails application.

Add this sample code to your `app/assets/javascripts/application.js` file

``` javascript
$(document).ready(function(){  
  
  var clip = new Clipboard('.clipboard-btn');
  console.log(clip);
	
});
```

*Note:* Here i am using `gem 'jquery-turbolinks'` for using the jquery $(document).ready function 

Add this sample code to your template file like `index.html.erb`

``` html
<!-- Target -->
<textarea id="bar">Mussum ipsum cacilds...</textarea>

<!-- Trigger -->
<button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
    Cut to clipboard
</button>
```
## Additional information

Additionally, you can define a **data-clipboard-action** attribute to specify if you want to either **copy** or **cut** content.

If you omit this attribute, **copy** will be used by default.

## Full documentation 

Read the clipboard.js documentation here http://zenorocha.github.io/clipboard.js/ for full usage information.


## Add Tooltips + Highlight animation: 

with Clipboard.js on button click using Bootstrap Tooltip

``` javascript

// Tooltip

$('button').tooltip({
  trigger: 'click',
  placement: 'bottom'
});

function setTooltip(btn, message) {
  $(btn).tooltip('hide')
    .attr('data-original-title', message)
    .tooltip('show');
}

function hideTooltip(btn) {
  setTimeout(function() {
    $(btn).tooltip('hide');
  }, 1000);
}<commit_msg>Update text<commit_after># clipboard-rails
[![Gem Version](https://badge.fury.io/rb/clipboard-rails.svg)](http://badge.fury.io/rb/clipboard-rails)

clipboard-rails gem is the integration of clipboard.js javascript library for your Rails 4 and Rails 5 applications.

clipboard.js is a modern approach to copy text to clipboard No Flash. No dependencies. Just 2kb
source: https://github.com/zenorocha/clipboard.js

Ruby gems url: https://rubygems.org/gems/clipboard-rails

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'clipboard-rails'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install clipboard-rails

Now you need to edit your `app/assets/javascripts/application.js` file and add the following line:
``` javascript
//= require clipboard
```

## Usage

Here is the example working code to test with your Rails application.

Add this sample code to your `app/assets/javascripts/application.js` file

``` javascript
$(document).ready(function(){  
  
  var clip = new Clipboard('.clipboard-btn');
  console.log(clip);
	
});
```

*Note:* Here i am using `gem 'jquery-turbolinks'` for using the jquery $(document).ready function 

Add this sample code to your template file like `index.html.erb`

``` html
<!-- Target -->
<textarea id="bar">Mussum ipsum cacilds...</textarea>

<!-- Trigger -->
<button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
    Cut to clipboard
</button>
```
## Additional information

Additionally, you can define a **data-clipboard-action** attribute to specify if you want to either **copy** or **cut** content.

If you omit this attribute, **copy** will be used by default.

## Full documentation 

Read the clipboard.js documentation here http://zenorocha.github.io/clipboard.js/ for full usage information.


## Add Tooltips + Highlight animation: 

Add Tooltips + Highlight animation with Clipboard.js on button click using Bootstrap Tooltip

``` javascript

// Tooltip

$('button').tooltip({
  trigger: 'click',
  placement: 'bottom'
});

function setTooltip(btn, message) {
  $(btn).tooltip('hide')
    .attr('data-original-title', message)
    .tooltip('show');
}

function hideTooltip(btn) {
  setTimeout(function() {
    $(btn).tooltip('hide');
  }, 1000);
}
{'fraction_non_alphanumeric': 0.13405238828967642, 'fraction_numerical': 0.0030816640986132513, 'mean_word_length': 4.277584204413473, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5945368', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1350, 'n_words': 449}