buggedcom discussing the shortcomings of issac newton

Joined: 18 Oct 2002 Posts: 682 Location: working from home
|
Posted: Sun Apr 23, 2006 5:21 pm Post subject: Faux Checkboxes |
|
|
| Code: | /**
* Creates Custom Checkboxes. Should be compatible across all browsers.
* @license LGPL
* @created 12.04.2006
* @author Oliver Lillie
* @email publicmail -at- buggedcom -dot- co -dot- uk
*/
fauxcheckbox = {
checked_path: 'images/checkbox/on.gif',
unchecked_path: 'images/checkbox/off.gif',
ani_to_checked_path: 'images/checkbox/to_on.gif',
ani_to_unchecked_path: 'images/checkbox/to_off.gif',
toggle: function(element, force)
{
var $checkbox = $ref(element);
var $img = $ref('_checkbox_'+element);
if(typeof $img.dragging == 'undefined' || !$img.dragging)
{
force = typeof force != 'undefined' ? force : null;
if (force === false || $img.src.substring($img.src.lastIndexOf("/")+1)=="on.gif" || $img.src.substring($img.src.lastIndexOf("_")+1)=="on.gif")
{
$img.src = this.ani_to_unchecked_path;
$checkbox.value = false;
setTimeout("$ref('"+$img.id+"').src = '"+this.unchecked_path+"';", 200);
}
else
{
$img.src = this.ani_to_checked_path;
$checkbox.value = true;
setTimeout("$ref('"+$img.id+"').src = '"+this.checked_path+"';", 200);
}
}
},
create: function(id, initstate, form)
{
var src = initstate ? this.checked_path : this.unchecked_path;
var str = '<img id="_checkbox_'+id+'" onclick="fauxcheckbox.toggle(\''+id+'\');" src="'+src+'" width="18" height="18" /><input type="hidden" name="' + id + '" id="' + id + '" value="null" />';
return str;
}
}; |
_________________ ~buggedcom
If anyone would like to buy me anything for all my hard work, my Amazon wish list is here or you could donate into my paypal account publicmail_at_buggedcom.co.uk
Thanks
Latest Projects 1 | 2 | 3 |
|