annotate media/js/shoutbox.js @ 265:1ba2c6bf6eb7

Closing #98. Animated GIFs were losing their transparency and animated properties when saved as avatars. Reworked the avatar save process to only run the avatar through PIL if it is too big. This preserves the original uploaded file if it is within the desired size settings. This may still mangle big animated gifs. If this becomes a problem, then maybe look into calling the PIL Image.resize() method directly. Moved the PIL image specific functions from bio.forms to a new module: core.image for better reusability in the future.
author Brian Neal <bgneal@gmail.com>
date Fri, 24 Sep 2010 02:12:09 +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 });