Sha256: 080cb9ab332339453c60e6fe1bdd77f99b02b933bd58006de30a0a3da9110f30
Contents?: true
Size: 1.23 KB
Versions: 7
Compression:
Stored size: 1.23 KB
Contents
I"á(function() { var toggleSwitch; $.fn.spinaSwitch = function() { return this.each(function() { var input, klass; if (!$(this).attr('data-plugin-switch')) { input = $(this); input.attr('data-plugin-switch', true); input.hide(); if (input.is(':checked')) { klass = "switch active"; } else { klass = "switch"; } return input.after('<a href="#' + input.attr("id") + '" class="' + klass + '"> <span class="knob"></span> </a>'); } }); }; $(document).on('click', 'a.switch', function(e) { return toggleSwitch(e); }); $(document).on('touchend', 'a.switch', function(e) { return toggleSwitch(e); }); toggleSwitch = function(e) { var checkbox, input; checkbox = $(e.currentTarget); input = $(checkbox.attr("href")); if (checkbox.hasClass('activated') || checkbox.hasClass('active')) { checkbox.removeClass('active'); checkbox.removeClass('activated'); checkbox.addClass('deactivated'); input.prop("checked", false); } else { checkbox.addClass('activated'); checkbox.removeClass('deactivated'); input.prop("checked", true); } return false; }; }).call(this); :ET
Version data entries
7 entries across 5 versions & 1 rubygems