annotate shoutbox/static/js/shoutbox_app.js @ 811:56b30c79f10e

Private messages refactor: start adding tests.
author Brian Neal <bgneal@gmail.com>
date Sun, 07 Sep 2014 13:12:19 -0500
parents ee87ea74d46b
children
rev   line source
bgneal@312 1 $(document).ready(function() {
bgneal@312 2 $('div.shoutbox-history table tr:odd').addClass('odd');
bgneal@312 3 $('.edit').editable('/shout/edit/', {
bgneal@312 4 loadurl : '/shout/text/',
bgneal@312 5 indicator : 'Saving...',
bgneal@312 6 tooltip : 'Click to edit your shout...',
bgneal@312 7 submit : 'OK',
bgneal@312 8 cancel : 'Cancel'
bgneal@312 9 });
bgneal@312 10 $('a.shout-del').click(function () {
bgneal@312 11 if (confirm('Really delete this shout?')) {
bgneal@312 12 var id = this.id;
bgneal@312 13 if (id.match(/^shout-del-(\d+)/)) {
bgneal@312 14 $.ajax({
bgneal@312 15 url: '/shout/delete/',
bgneal@312 16 type: 'POST',
bgneal@312 17 data: { id : RegExp.$1 },
bgneal@312 18 dataType: 'text',
bgneal@312 19 success: function (id) {
bgneal@312 20 var id = '#shout-del-' + id;
bgneal@312 21 $(id).parents('tr').fadeOut(1500, function () {
bgneal@312 22 $('div.shoutbox-history table tr:visible:even').removeClass('odd');
bgneal@312 23 $('div.shoutbox-history table tr:visible:odd').addClass('odd');
bgneal@312 24 });
bgneal@312 25 },
bgneal@312 26 error: function (xhr, textStatus, ex) {
bgneal@312 27 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
bgneal@312 28 xhr.responseText);
bgneal@312 29 }
bgneal@312 30 });
bgneal@312 31 }
bgneal@312 32 }
bgneal@312 33 return false;
bgneal@312 34 });
bgneal@312 35 $('.shout-flag').click(function () {
bgneal@312 36 var id = this.id;
bgneal@312 37 if (id.match(/^shout-flag-(\d+)/)) {
bgneal@312 38 id = RegExp.$1;
bgneal@312 39 if (confirm('Only flag a shout if you feel it is spam, abuse, violates site rules, ' +
bgneal@312 40 'or is not appropriate. ' +
bgneal@312 41 'A moderator will be notified and will review the shout. ' +
bgneal@312 42 'Are you sure you want to flag this shout?')) {
bgneal@312 43 $.ajax({
bgneal@312 44 url: '/shout/flag/',
bgneal@312 45 type: 'POST',
bgneal@312 46 data: { id : id },
bgneal@312 47 dataType: 'text',
bgneal@312 48 success: function(response) {
bgneal@312 49 alert(response);
bgneal@312 50 },
bgneal@312 51 error: function (xhr, textStatus, ex) {
bgneal@312 52 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
bgneal@312 53 xhr.responseText);
bgneal@312 54 }
bgneal@312 55 });
bgneal@312 56 }
bgneal@312 57 }
bgneal@312 58 return false;
bgneal@312 59 });
bgneal@312 60 });