Sha256: c4507c9f3ceb2e59fbe2b4bd82039a5251259c0175d659b612507b9059a885cc

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

$(function() {

function updateSubmission(url, spam, callback) {
  $.ajax({
    type: 'PUT',
    url: url,
    data: { spam: spam },    
    dataType: 'json',
    success: function() {
      Wheelhouse.Flash.message("Submission updated.");
      callback();
    }
  });
  
  Wheelhouse.Flash.loading("Updating submission.");
}

function clickHandler(spam) {
  return function() {
    var url = $(this).attr('href');
    var row = $(this).closest('tr');
    
    updateSubmission(url, spam, function() {
      row.remove();
    });
    
    return false;
  }
}

$('#submissions').on('click', 'a.mark-spam', clickHandler(true));
$('#submissions').on('click', 'a.not-spam', clickHandler(false));

$('button.mark-spam').click(function() {
  var url = $(this).closest('form').attr('action');
  
  updateSubmission(url, true, function() {
    $('button.mark-spam').hide();
    $('button.not-spam').show();
  });
  
  return false;
});

$('button.not-spam').click(function() {
  var url = $(this).closest('form').attr('action');
  
  updateSubmission(url, false, function() {
    $('button.not-spam').hide();
    $('button.mark-spam').show();
  });
  
  return false;
});

});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wheelhouse-forms-1.2.2 app/assets/javascripts/wheelhouse-forms/submissions.js
wheelhouse-forms-1.2.1 app/assets/javascripts/wheelhouse-forms/submissions.js
wheelhouse-forms-1.2 app/assets/javascripts/wheelhouse-forms/submissions.js
wheelhouse-forms-1.1 app/assets/javascripts/wheelhouse-forms/submissions.js