Sha256: a07087b2a79f0bc921c60c58ba224fba796a296ba447c843a433becfbae5159b
Contents?: true
Size: 1.83 KB
Versions: 14
Compression:
Stored size: 1.83 KB
Contents
$(function() { // Assignment $('form.assignment').each(function() { var form = $(this), spinner = $('.spinner', this); form.ajaxForm({ dataType: 'json', beforeSubmit: function() { spinner.show(); }, success: function(data, status, jqx) { spinner.hide(); if (!data.success) { alert('There was an issue assigning this approval!') } }, error: function(jqx, status, error) { spinner.hide(); alert('There was an issue assigning this approval!') }, }); $('select', this).change(function() { form.submit(); }); }); // Approval and Rejection var actionLinks = $('td.actions a'); actionLinks.click(function() { if ($(this).hasClass('disabled')) return false; var verbing = ($(this).hasClass('approve') ? 'approving' : 'rejecting'), row = $(this).parents('tr'), settings = { dataType: 'json', url: $(this).attr('href'), beforeSubmit: function() { actionLinks.addClass('disabled'); }, success: function(data) { actionLinks.removeClass('disabled'); if (!data.success) { if (data.message) { alert(data.message); } else { alert('There was an issue ' + verbing + ' the approval.'); } } else { row.fadeOut('fast', row.remove); } }, error: function() { actionLinks.removeClass('disabled'); alert('There was an issue ' + verbing + ' the approval.'); } }; if ($(this).hasClass('reject')) { var reason = prompt('Reason for rejection'); if (reason) settings['data'] = {reason: reason}; } $.ajax(settings); return false; }); });
Version data entries
14 entries across 7 versions & 2 rubygems