annotate media/js/shoutbox.js @ 177:9b63ad1f2ad2
Fixing #59, again. Django ticket 13093 was fixed allowing cache_page to work in the URLconf.
author |
Brian Neal <bgneal@gmail.com> |
date |
Mon, 15 Mar 2010 03:26:38 +0000 |
parents |
b43e1288ff80 |
children |
4557974db0e0 |
rev |
line source |
bgneal@12
|
1 $(document).ready(function() {
|
bgneal@12
|
2 var submit = $('#shoutbox-submit');
|
bgneal@12
|
3 submit.click(function () {
|
bgneal@12
|
4 var input = $('#shoutbox-smiley-input');
|
bgneal@27
|
5 var msg = $.trim(input.val());
|
bgneal@12
|
6 if (msg.length == 0) {
|
bgneal@12
|
7 return false;
|
bgneal@12
|
8 }
|
bgneal@12
|
9 submit.attr('disabled', 'disabled');
|
bgneal@150
|
10 $.ajax({
|
bgneal@150
|
11 url: '/shout/shout/',
|
bgneal@150
|
12 type: 'POST',
|
bgneal@150
|
13 data: { msg: msg },
|
bgneal@150
|
14 dataType: 'html',
|
bgneal@150
|
15 success: function (data, textStatus) {
|
bgneal@12
|
16 input.val('');
|
bgneal@12
|
17 if (data != '') {
|
bgneal@12
|
18 $('#shoutbox-shout-container').prepend(data);
|
bgneal@12
|
19 $('#shoutbox-shout-container p:first').fadeIn(2500);
|
bgneal@12
|
20 }
|
bgneal@12
|
21 submit.removeAttr('disabled');
|
bgneal@12
|
22 },
|
bgneal@150
|
23 error: function (xhr, textStatus, ex) {
|
bgneal@150
|
24 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
|
bgneal@150
|
25 xhr.responseText);
|
bgneal@150
|
26 }
|
bgneal@150
|
27 });
|
bgneal@12
|
28 return false;
|
bgneal@12
|
29 });
|
bgneal@12
|
30 var smilies_loaded = false;
|
bgneal@12
|
31 var smiley_frame = $('#shoutbox-smiley-frame');
|
bgneal@12
|
32 $('#shoutbox-smilies').click(function () {
|
bgneal@12
|
33 smiley_frame.toggle();
|
bgneal@12
|
34 if (!smilies_loaded) {
|
bgneal@12
|
35 smiley_frame.load('/smiley/farm/', function () {
|
bgneal@12
|
36 $('#shoutbox-busy-icon').hide();
|
bgneal@123
|
37 var txt = $("#shoutbox-smiley-input")[0];
|
bgneal@123
|
38 $('#shoutbox-smiley-frame img').click(function() {
|
bgneal@123
|
39 txt.value += ' ' + this.alt + ' ';
|
bgneal@123
|
40 txt.focus();
|
bgneal@123
|
41 });
|
bgneal@12
|
42 smilies_loaded = true;
|
bgneal@12
|
43 });
|
bgneal@12
|
44 }
|
bgneal@12
|
45 });
|
bgneal@12
|
46 });
|