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

Version Path
spina-0.6.29 test/dummy/tmp/cache/assets/development/sprockets/v3.0/HuTHnd7l574L8dquI1Nk4S_Vd7sKxh3TwjwLbxKcTi0.cache
spina-0.6.29 test/dummy/tmp/cache/assets/test/sprockets/v3.0/qz1izVwjwl4okwUBI3BoiQAGBbSmIK-7sltRCuvlhtg.cache
spina-0.6.29 test/dummy/tmp/cache/assets/development/sprockets/v3.0/qz1izVwjwl4okwUBI3BoiQAGBbSmIK-7sltRCuvlhtg.cache
spina-0.6.28 test/dummy/tmp/cache/assets/development/sprockets/v3.0/HuTHnd7l574L8dquI1Nk4S_Vd7sKxh3TwjwLbxKcTi0.cache
spina-0.6.27 test/dummy/tmp/cache/assets/development/sprockets/v3.0/HuTHnd7l574L8dquI1Nk4S_Vd7sKxh3TwjwLbxKcTi0.cache
spina-0.6.26 test/dummy/tmp/cache/assets/development/sprockets/v3.0/HuTHnd7l574L8dquI1Nk4S_Vd7sKxh3TwjwLbxKcTi0.cache
spina-0.6.25 test/dummy/tmp/cache/assets/development/sprockets/v3.0/HuTHnd7l574L8dquI1Nk4S_Vd7sKxh3TwjwLbxKcTi0.cache