All Projects → sadiqmmm → Clipboard Rails

sadiqmmm / Clipboard Rails

Licence: mit
clipboard.js javascript library integration for your Rails 4 and Rails 5 applications

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Clipboard Rails

Clipmenu
Clipboard management using dmenu
Stars: ✭ 634 (+780.56%)
Mutual labels:  clipboard
Clipboard.js
✂️ Modern copy to clipboard. No Flash. Just 3kb gzipped 📋
Stars: ✭ 31,525 (+43684.72%)
Mutual labels:  clipboard
Diodon
Aiming to be the best integrated clipboard manager for the Gnome/Unity desktop
Stars: ✭ 60 (-16.67%)
Mutual labels:  clipboard
Datapasta
On top of spaghetti, all covered in cheese....
Stars: ✭ 704 (+877.78%)
Mutual labels:  clipboard
Unicopy
Unicode command-line codepoint dumper
Stars: ✭ 16 (-77.78%)
Mutual labels:  clipboard
Copy To Clipboard
✂️ Modern copy to clipboard. No Flash.
Stars: ✭ 39 (-45.83%)
Mutual labels:  clipboard
Pbgopy
Copy and paste between devices
Stars: ✭ 612 (+750%)
Mutual labels:  clipboard
Imgursniper
📷 A quick and easy Image, Screenshot and Screen recording sharing tool
Stars: ✭ 69 (-4.17%)
Mutual labels:  clipboard
Crossclip
Sync clipboard across macOS/Linux/Windows on LAN
Stars: ✭ 22 (-69.44%)
Mutual labels:  clipboard
Cbrain
CBRAIN is a flexible Ruby on Rails framework for accessing and processing of large data on high-performance computing infrastructures.
Stars: ✭ 51 (-29.17%)
Mutual labels:  rails-application
Clipboard
clipboard for golang
Stars: ✭ 720 (+900%)
Mutual labels:  clipboard
Zeroclipboard
The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
Stars: ✭ 6,650 (+9136.11%)
Mutual labels:  clipboard
React Antd Admin Template
一个基于React+Antd的后台管理模版,在线预览https://nlrx-wjc.github.io/react-antd-admin-template/
Stars: ✭ 1,022 (+1319.44%)
Mutual labels:  clipboard
Osem
Open Source Event Manager. An event management tool tailored to Free and Open Source Software conferences.
Stars: ✭ 649 (+801.39%)
Mutual labels:  rails-application
Enhanced Github
🚀 Browser extension to display size of each file, download link and copy file contents directly to the clipboard
Stars: ✭ 1,146 (+1491.67%)
Mutual labels:  clipboard
Pasteex
📋 Paste As File 把剪贴板的内容直接粘贴为文件
Stars: ✭ 634 (+780.56%)
Mutual labels:  clipboard
Real World Rails
Real World Rails applications and their open source codebases for developers to learn from
Stars: ✭ 982 (+1263.89%)
Mutual labels:  rails-application
Ember Cli Clipboard
A simple ember wrapper around clipboard.js
Stars: ✭ 72 (+0%)
Mutual labels:  clipboard
Execution time
How fast is your code? See it directly in Rails console.
Stars: ✭ 67 (-6.94%)
Mutual labels:  rails-application
Potato Library
Easy to use Utility library for Android
Stars: ✭ 45 (-37.5%)
Mutual labels:  clipboard

clipboard-rails

Gem Version

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:

gem 'clipboard-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install clipboard-rails

Note: After adding the gem to your gem file and running the bundle, restart rails server.

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

//= 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

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

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

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

<!-- Trigger -->
<button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
    Copy 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

// Tooltip

$('.clipboard-btn').tooltip({
  trigger: 'click',
  placement: 'bottom'
});

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

function hideTooltip(btn) {
  setTimeout(function() {
    $(btn).tooltip('hide');
  }, 1000);
}

// Clipboard

var clipboard = new Clipboard('.clipboard-btn');

clipboard.on('success', function(e) {
  setTooltip(e.trigger, 'Copied!');
  hideTooltip(e.trigger);
});

clipboard.on('error', function(e) {
  setTooltip(e.trigger, 'Failed!');
  hideTooltip(e.trigger);
});
<!-- Example 1: Animation with single button HTML source-->
<button class="clipboard-btn btn btn-primary" data-clipboard-text="It worked!">Click me</button>

<!-- Example 2: with Target source -->
<textarea id="bar">Mussum ipsum cacilds...</textarea>

<!-- Trigger -->
<button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
    Copy to clipboard
</button>

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake false to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sadiqmmm/clipboard-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].