iCheckbox fixing 1
plugin broken in jQuery 1.5.x and 1.6.x
by mikkelbreum
HTML
<h2>Modified version of iCheckbox that works with jQuery 1.6.x</h2>
<br>
<hr>
<input class="icheck" type="checkbox">
<hr>
<br>
<p id="out">--</p>
CSS
.iCheckbox_container {
height:27px;
width:94px;
position: relative;
overflow: hidden;
}
.iCheckbox_switch {
height:27px;
width:94px;
background-image:url(http://www.jooze.dk/iphone_switch.png); /* your actual slider image */
background-repeat:none;
background-position:0px;
}
JavaScript
/*
* iCheckbox - Inspired Checkbox v0.1
*
* Convert a checkbox or multiple checkboxes into iphone style switches.
*
* This is based on the jQuery iphoneSwitch plugin by Daniel LaBare.
*
* Features:
* * Because checkboxes are used, this is compatable with having javascript off for form submission.
* * Affects only checkboxes.
* * Synchronizes the actual state of the checkbox for on or off status.
* * Completely self-contained for each checkbox.
* * Changes fire the onchange event of your checkbox.
* * Relies purely on css for styling... no passing anything but your slider image.
* * Because functionality is decoupled from CSS, you can assign custom CSS classes if you wish making it possible for multiple version per page.
* * Completely inline like a normal checkbox. No sliding-door-float madness.
*
* iphoneSwitch Author: Daniel LaBare
* iCheckbox Author: Bryn Mosher
* iphoneSwitch Date: 2/4/2008
* iCheckbox date: 2/26/2010-2/27/2010 (like most of you I'm a nite owl :P)
*/
// convert the matched element into an iCheckbox if it is a checkbox input
jQuery.fn.iCheckbox = function(start_state, options) {
if ( jQuery(this ).attr('type') == 'checkbox' ) {
// define default settings
var settings = jQuery.extend( {
// switch_container_src is the outer frame image of the slider
// you assign the actual slider image via css
switch_container_src: 'images/iphone_switch_container.gif',
// The height of your slider
switch_height: 27,
// The width of your slider
switch_width: 94,
// switch_speed is the speed of the slider animation.
// Warning: Your onchange() even won't be fired until the end of this!
switch_speed: 150,
// How far your actual slider image has to move to change to the "off" state.
// This can be either positive or...