Rails wrapper for the jQuery OnOff plugin, transform checkboxes into toggle switches.
From original jQuery OnOff repository:
Toggle switches made for the web are often solely constructed to change when clicked or tapped, animating side-to-side as they toggle. That's a good start, but some people like to slide toggle switches. Javascript is used for creation and for adding the sliding functionality, but the toggle is purely CSS.
Customize the look of your toggle switch using proto.io's generator.
Installation
Add this line to your application's Gemfile:
gem 'jquery-onoff-rails', '~> 0.4.0'
and run bundle install
.
Or install it yourself as:
gem install jquery-onoff-rails
Usage
In your application.css
, include ONE of the css file:
/*
* English version
*= require jquery.onoff-en
*/
/*
* Spanish version
*= require jquery.onoff-es
*/
In your application.js
, include the js file:
//= require jquery.onoff
In you view, use the onoff helper. It will create the input checkbox and all other tags required to create the Onoff switch:
<%= onoff target: "myTarget" %>
Contributing
- 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