test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.1 KiB

;(function()
{
var Switchery = function(elem, params){
var obj = $(elem);
obj.hide();
var small = obj.hasClass('small');
var checked = elem.checked;
var switchery = $('<div class="switchery ' + (small?"switchery-small":"") +'"><small></small></div>');
obj.after(switchery);
if(checked){
switchery.addClass('checked');
}
switchery.click(function(e){
switchery.toggleClass('checked');
obj.click && obj.trigger('click',e);
});
return switchery;
}
$.fn.switchery = function(params)
{
var lists = this,
retval = this;
lists.each(function()
{
var plugin = $(this).data("switchery");
if (!plugin) {
$(this).data("switchery", new Switchery(this, params));
$(this).data("switchery-id", new Date().getTime());
} else {
if (typeof params === 'string' && typeof plugin[params] === 'function') {
retval = plugin[params]();
}
}
});
return retval || lists;
};
})();