| 27 | }; |
| 28 | |
| 29 | var update = function(event) { |
| 30 | var $tr = findTr(event); |
| 31 | $tr.find('button').attr('disabled', 'disabled'); |
| 32 | var data = { |
| 33 | published: $tr.hasClass('unpublished') |
| 34 | }; |
| 35 | var id = $tr.attr('data-id'); |
| 36 | $.ajax({ |
| 37 | url: '/api/articles/' + id, |
| 38 | type: 'PUT', |
| 39 | contentType: 'application/json', |
| 40 | data: JSON.stringify({article: data}), |
| 41 | success: function(dataResponse, status, xhr) { |
| 42 | $tr.find('button').removeAttr('disabled'); |
| 43 | $('.alert').addClass('hidden'); |
| 44 | if (data.published) { |
| 45 | $tr.removeClass('unpublished').find('.glyphicon-play').removeClass('glyphicon-play').addClass('glyphicon-pause'); |
| 46 | } else { |
| 47 | $tr.addClass('unpublished').find('.glyphicon-pause').removeClass('glyphicon-pause').addClass('glyphicon-play'); |
| 48 | } |
| 49 | } |
| 50 | }); |
| 51 | }; |
| 52 | |
| 53 | $(document).ready(function(){ |
| 54 | var $element = $('.admin tbody'); |