-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e03c5c7
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
jQuery Radiobutton Plugin by Tomek Wójcik | ||
Dead simple custom radiobuttons jQuery plugin | ||
|
||
This is a very simple radiobutton plugin for jQuery. It's simple, lightweight and easily styllable. | ||
|
||
See: http://tomekwojcik.github.com/jQuery-Custom-Radiobuttons/ for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* jQuery custom checkboxes | ||
* | ||
* Copyright (c) 2010 Tomasz Wójcik (bthlabs.pl) | ||
* Licensed under the MIT License: | ||
* http://www.opensource.org/licenses/mit-license.php | ||
* | ||
* @version 1.0 | ||
* @category visual | ||
* @package jquery | ||
* @subpakage ui.checkbox | ||
* @author Tomasz Wójcik <tomek@bthlabs.pl> | ||
**/ | ||
jQuery.fn.radiobutton = function(options) { | ||
var defaults = { | ||
className: 'jquery-radiobutton', | ||
checkedClass: 'jquery-radiobutton-on' | ||
}; | ||
|
||
var settings = jQuery.extend(defaults, options || {}); | ||
|
||
return this.each(function() { | ||
var _this = jQuery(this); | ||
|
||
var _replacement = jQuery( | ||
'<div class="' + settings.className + '-wrapper">' + | ||
'<a class="' + settings.className + '" href="#" name="' + _this.attr('id') + '" rel="' + _this.attr('name') + '"></a>' + | ||
'</div>' | ||
); | ||
|
||
if (_this.attr('checked') == true) { | ||
jQuery('a', _replacement).addClass(settings.checkedClass); | ||
} // eof if() | ||
|
||
jQuery('a', _replacement).click(function() { | ||
var _input = jQuery('input#' + jQuery(this).attr('name'), _replacement.parent()); | ||
if (_input.attr('checked') == true) { | ||
_input.removeAttr('checked'); | ||
} else { | ||
_input.attr('checked', true); | ||
} // eof if() | ||
_input.change(); | ||
|
||
return false; | ||
}); | ||
jQuery(_this).change(function() { | ||
var _input = jQuery(this); | ||
|
||
jQuery('a[rel="' + _input.attr('name') + '"].' + settings.checkedClass).removeClass(settings.checkedClass); | ||
|
||
if (_input.attr('checked') == true) { | ||
jQuery('a[name=' + _input.attr('id') + ']', _replacement.parent()).addClass(settings.checkedClass); | ||
} else { | ||
jQuery('a[name=' + _input.attr('id') + ']', _replacement.parent()).removeClass(settings.checkedClass); | ||
} // eof if() | ||
}); | ||
|
||
_this.css({ 'position': 'absolute', 'top': '-200px', 'left': '-200px'}).before(_replacement); | ||
_replacement.parent().css('overflow', 'hidden'); | ||
}); | ||
}; |