clipboard-toastr-rails gem is the integration of clipboard.js and toastr javascript library(using 2.2 Version) for your Rails 4, 5 application.
Ruby gems url: https://rubygems.org/gems/clipboard-toastr-rails
Add this line to your application's Gemfile:
gem 'clipboard-toastr-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install clipboard-toastr-rails
Now you need to edit your app/assets/javascripts/application.js
file
and add the following line:
//= require clipboard-toastr
And you need to edit your app/assets/stylesheets/application.css
file
and add the following line:
*= require toastr
If Use app/assets/stylesheets/application.scss
file
@import "toastr";
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(){
clip = new Clipboard('.copy-target')
toastr.options = {
"positionClass": "toast-bottom-center",
....
....
}
$(".copy-target").click(function() {
toastr.info "Copy Success Alert"
});
target_clip = new Clipboard('.copy-target1')
toastr.options = {
"positionClass": "toast-top-center",
....
....
}
$(".copy-target1").click(function() {
toastr.info "Copy Success Alert"
});
});
<html>
<head>
...
</head>
<body>
...
...
<input id="copy-content" value="This is Copy Content"/>
<span class="copy-target1" data-clipboard-target="#copy-content">Copy This Content</span>
...
...
<span class="copy-target" data-clipboard-text="COPY CONTENT">Copy Link</span>
...
...
</body>
</html>
The Documentation is at
Current Version 1.3.0
This link listing Change Log
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
The gem is available as open source under the terms of the MIT License.