2017 © Pedro Peláez
 

library radiosforbuttons

image

thatsus/radiosforbuttons

  • Wednesday, April 20, 2016
  • by thatsus
  • Repository
  • 0 Watchers
  • 0 Stars
  • 10,560 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 13 % Grown

The README.md

radiosforbuttons

jQuery plugin for transforming radio-buttons in true beautiful Bootstrap buttons., (*1)

Demo

Page

Requirements

The requirements are + jQuery + Bootstrap (but it really needs only the css for buttons, if you're not already using the entire framework at your project, get only the bootstrap-buttons.min.css file) + the jquery.radioforbuttons.js file, either minified or not (1.9k vs 2.9k)., (*2)

Just include them all., (*3)

Usage

To use you must have a set of radio-buttons (defined by <input type="radio">) with name, value, unique ids and a label (defined by <label for="id"></label>) for each one. All these elements must be inside a div (or some other block element), which will be, by its time, called on the plugin invocation. The div can be anywhere inside a form. The html of the button will be the content of the label for each button. The radio-buttons will be preserved at the DOM, hidden, and their checked properties altered on each click at the resulting buttons. It is their value which will be sent to the server on any form submit. Simple example:, (*4)

<!DOCTYPE html>
<link rel="stylesheet" href="bootstrap-buttons.min.css">





Group

Change the group option from the default true to false if you don't want the buttons to be in bootstrap button group (as in the .btn-group class)., (*5)

Vertical

If you want stacked options, just mark option vertical as true:, (*6)

$('#radios_div').radiosforbuttons({ vertical: true })

The widths of the vertically stacked buttons will be equalized unless you set autowidth to false., (*7)

Colors

As you know, bootstrap buttons have colors. You can color the radio buttons in two ways:, (*8)

Calling radiosforbuttons with the color or buttonstyle options setted

Just set the option you want to use with the value of the color you will want for all the buttons. Both the bootstrap button classes names or simply a color name:, (*9)

$('#radios_div').radiosforbuttons({ color: 'black' })
$('#radios_div').radiosforbuttons({ buttonstyle: 'btn-inverse' })

Using data properties on the input element

You can assign color to buttons using the data properties button-color or button-bootstrap-class, the values are the same for the example above:, (*10)



Margin

Because of a difference of 2px (I think) on the button margins on Chrome and Firefox which bootstrap apparently doesn't cover, I added this property so you could make the buttons of the group nearer or farther. However, due to other improvement isn't necessary to change it, unless you want to make your buttons farther, then it's a cool thing. Just do:, (*11)

$('#radios_div').radiosforbuttons({ margin: 4 })

It also works for vertically stacked buttons., (*12)

Reference

option type default
group boolean true
color string white
buttonstyle string ''
vertical boolean false
autowidth boolean true
margin integer 0

The Versions

20/04 2016

dev-master

9999999-dev

  Sources   Download

20/04 2016

dev-thatsus-patch-1

dev-thatsus-patch-1

  Sources   Download

20/04 2016

v1.3.2

1.3.2.0

  Sources   Download

20/04 2016

v1.3.1

1.3.1.0

  Sources   Download

04/01 2016

v1.3

1.3.0.0

  Sources   Download

24/08 2015

v1.2.1

1.2.1.0

  Sources   Download

24/08 2015

v1.2.0

1.2.0.0

  Sources   Download

24/08 2015

v1.1.0

1.1.0.0

  Sources   Download

19/08 2015

v1.0.0

1.0.0.0

  Sources   Download