$(document).ready(function(){
$(".checkbox").Sswitch({
onSwitchChange: function(_this) {
alert("Status: "+_this.options.state);
}
});
});
(function($) {
$.fn.Sswitch = function(element, options ) {
this.$element = $(this);
this.options = $.extend({}, $.fn.Sswitch.defaults, {
state: this.$element.is(":checked"),
disabled: this.$element.is(":disabled"),
readonly: this.$element.is("[readonly]"),
parentClass: this.$element.data("parent"),
onSwitchChange: element.onSwitchChange
},options);
this.$container = $("<div>", {
"class": (function(_this){
return function(){
var classes;
classes = [_this.options.parentClass];
classes.push(_this.options.state ? "" + _this.options.parentClass + "-on" : "" + _this.options.parentClass + "-off");
if (_this.options.disabled) {
classes.push("" + _this.options.parentClass + "-disabled");
}
if (_this.options.readonly) {
classes.push("" + _this.options.parentClass + "-readonly");
}
if (_this.$element.attr("id")) {
classes.push("" + _this.options.parentClass + "-id-" + (_this.$element.attr("id")));
}
return classes.join(" ");