Sha256: f90fcae47020957a17a2761c1e63cd3f31d3d48952a1fb80892722ebbf1eabaf

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

jQuery(document).ready(function($) {
  new activableOption();
});

var activableOption = function(){
  var _this    = this;
  this.$links  = $('.activable');

  this.startup = function(){
    if(!this.$links[0]){ return false; }

    this.$links.on('change', function(event) {
      event.preventDefault();

      if($(this).is(':checked')){
        _this.active($(this));
      }else{
        _this.inactive($(this));
      }
    });
  },

  this.active = function($link){
    $.ajax({
      url: '/loldesign_publisher/activables/'+$link.data('resource')+'/'+$link.data('id')+'.json',
      type: 'POST',
      dataType: 'json'
    })
    .done(function() {
      $link.val(true);
    })
    .fail(function() {
      console.log("error");
    });
  },
  this.inactive = function($link){
    $.ajax({
      url: '/loldesign_publisher/activables/'+$link.data('resource')+'/'+$link.data('id')+'.json',
      type: 'DELETE',
      dataType: 'json'
    })
    .done(function() {
      $link.val(false);
    })
    .fail(function() {
      console.log("error");
    });
  },

  this.startup();
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
loldesign_publisher-2.0.0 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.5.1 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.5.0 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.4.0 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.6 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.4 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.3 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.2 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.1 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.3.0 app/assets/javascripts/loldesign_publisher/activable.js
loldesign_publisher-1.1.0 app/assets/javascripts/loldesign_publisher/activable.js