Skip to content

Commit c02bcca

Browse files
author
Tom Boutell
committed
Behold jquery-radio
1 parent 203d13d commit c02bcca

File tree

5 files changed

+72
-127
lines changed

5 files changed

+72
-127
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
# jquery-images-ready
1+
# jquery-radio
22

3-
<a href="http://apostrophenow.org/"><img src="https://raw.github.com/punkave/jquery-images-ready/master/logos/logo-box-madefor.png" align="right" /></a>
3+
<a href="http://apostrophenow.org/"><img src="https://raw.github.com/punkave/jquery-radio/master/logos/logo-box-madefor.png" align="right" /></a>
44

5-
imagesReady waits until the size of certain images is known, then tells you the maximum width, maximum height, and maximum ratio of height to width of all the images. This is super useful for implementing slideshows and anything else where you need to know the worst case before proceeding, or simply for any situation where you need to be sure of the image dimensions before proceeding. Well-tested back to IE8.
5+
`jquery-radio` makes it easy to get or set the current value of a group of radio buttons, filling a gap in jQuery's `$.val()`.
66

77
## How to Use
88

9-
$('.my-images').imagesReady(function(maxWidth, maxHeight, maxHeightToWidth) {
10-
// Your code here
11-
});
9+
Select *all* of the buttons in the group and call `.radio()`:
1210

13-
Note that `imagesReady` will wait for all of the images either matching the selector directly or contained within elements that do match the selector. This is very useful when you wish to wait for all of the images in a slideshow. If you want to match only certain images, though, you can use filters in your selector to be more specific.
11+
// Check the box with value="5"
12+
$('input.my-radio-group').radio(5);
13+
// Get the value of the checked box
14+
var value = $('input.my-radio-group').radio();
1415

15-
*The reported sizes are always the true size, regardless of any CSS that may be in effect.*
16-
17-
"Why `maxHeightToWidth`?" This ratio is useful when you are using `width: 100%` to size images and allowing the height to scale freely. In that situation it is important to know what the greatest height will be, so that you can size a slideshow intelligently to avoid jumpiness when the user scrolls below the slideshow. You can determine this maximum height by multiplying the width of the containing element by `maxHeightToWidth`.
18-
19-
For a sweet jQuery slideshow plugin that takes advantage of this, check out [projector](http://github.com/punkave/jquery-projector).
16+
This example assumes you have several radio buttons that all have the `.my-radio-group` class.
2017

2118
### Requirements
2219

23-
You need jQuery, of course. `jquery-images-ready` is actively supported with jQuery 1.9 and 2.0 but may work with older versions.
20+
You need jQuery, of course. `jquery-radio` is actively supported with jQuery 1.9 and 2.0 but should work fine with older versions.
2421

2522
## About P'unk Avenue and Apostrophe
2623

27-
`jquery-images-ready` was created at [P'unk Avenue](http://punkave.com) for use in Apostrophe, an open-source content management system built on node.js. If you like `jquery-images-ready` you should definitely [check out apostrophenow.org](http://apostrophenow.org). Also be sure to visit us on [github](http://github.com/punkave).
24+
`jquery-radio` was created at [P'unk Avenue](http://punkave.com) for use in Apostrophe, an open-source content management system built on node.js. If you like `jquery-radio` you should definitely [check out apostrophenow.org](http://apostrophenow.org). Also be sure to visit us on [github](http://github.com/punkave).
2825

2926
## Support
3027

31-
Feel free to open issues on [github](http://github.com/punkave/jquery-images-ready).
28+
Feel free to open issues on [github](http://github.com/punkave/jquery-radio).
3229

33-
<a href="http://punkave.com/"><img src="https://raw.github.com/punkave/jquery-images-ready/master/logos/logo-box-builtby.png" /></a>
30+
<a href="http://punkave.com/"><img src="https://raw.github.com/punkave/jquery-radio/master/logos/logo-box-builtby.png" /></a>
3431

images-ready.jquery.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

jquery.images-ready.js

Lines changed: 0 additions & 75 deletions
This file was deleted.

jquery.radio.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// radio: a jQuery plugin that makes it easy to set or get the
2+
// current value of a group of radio buttons.
3+
//
4+
// Copyright 2013 P'unk Avenue LLC
5+
//
6+
// Please see:
7+
//
8+
// https://github.com/punkave/jquery-radio
9+
//
10+
// For complete documentation.
11+
12+
(function( $ ){
13+
$.fn.radio = function(value) {
14+
var $els = this;
15+
if (value === undefined) {
16+
return $els.filter(':checked').val();
17+
} else {
18+
$.each($els, function() {
19+
$(this).attr('checked', $(this).attr('value') === value);
20+
});
21+
}
22+
};
23+
})( jQuery );

radio.jquery.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "radio",
3+
"title": "radio",
4+
"description": "radio lets you get and set the current value of a group of radio buttons, filling a gap in jQuery's $.val. It is not a replacement for radio buttons. It just makes working with them pleasant.",
5+
"keywords": ["radio", "button", "apostrophe", "punkave"],
6+
"version": "0.1.0",
7+
"author": {
8+
"name": "P'unk Avenue",
9+
"url": "http://punkave.com/"
10+
},
11+
"maintainers": [
12+
{
13+
"name": "Tom Boutell",
14+
"email": "tom@punkave.com",
15+
"url": "http://punkave.com"
16+
},
17+
{
18+
"name": "Kyle Stetz",
19+
"email": "kyle@punkave.com",
20+
"url": "http://punkave.com"
21+
}
22+
],
23+
"licenses": [
24+
{
25+
"type": "MIT",
26+
"url": "https://github.com/punkave/jquery-radio/LICENSE"
27+
}
28+
],
29+
"bugs": "https://github.com/punkave/jquery-radio/issues",
30+
"homepage": "https://github.com/punkave/jquery-radio",
31+
"docs": "https://github.com/punkave/jquery-radio",
32+
"download": "https://github.com/punkave/jquery-radio",
33+
"dependencies": {
34+
"jquery": ">=1.9"
35+
}
36+
}

0 commit comments

Comments
 (0)