annotate media/js/shoutbox.js @ 288:4ba879ccdc62

Adding all the smilies from the old site as extra smilies
author Brian Neal <bgneal@gmail.com>
date Sun, 05 Dec 2010 20:58:58 +0000
parents 4557974db0e0
children 0eed8161ca39
rev   line source
bgneal@12 1 $(document).ready(function() {
bgneal@272 2
bgneal@272 3 var numShouts = $('#shoutbox-shout-container > p').size();
bgneal@272 4 var sbCycleOpts = null;
bgneal@272 5 var sbCycle = $('#shoutbox-shout-container').cycle({
bgneal@272 6 fx: 'scrollUp',
bgneal@272 7 timeout: 5000,
bgneal@272 8 pause: 1,
bgneal@272 9 next: '#shoutbox-next',
bgneal@272 10 prev: '#shoutbox-prev',
bgneal@272 11 before: function(curr, next, opts) {
bgneal@272 12 if (!opts.addSlide || sbCycleOpts) return;
bgneal@272 13 sbCycleOpts = opts;
bgneal@272 14 }
bgneal@272 15 });
bgneal@272 16 function addShout(shout) {
bgneal@272 17 ++numShouts;
bgneal@272 18 sbCycleOpts.addSlide(shout);
bgneal@272 19 $('#shoutbox-shout-container').cycle(numShouts - 1);
bgneal@272 20 }
bgneal@272 21
bgneal@12 22 var submit = $('#shoutbox-submit');
bgneal@12 23 submit.click(function () {
bgneal@12 24 var input = $('#shoutbox-smiley-input');
bgneal@27 25 var msg = $.trim(input.val());
bgneal@12 26 if (msg.length == 0) {
bgneal@12 27 return false;
bgneal@12 28 }
bgneal@12 29 submit.attr('disabled', 'disabled');
bgneal@150 30 $.ajax({
bgneal@150 31 url: '/shout/shout/',
bgneal@150 32 type: 'POST',
bgneal@150 33 data: { msg: msg },
bgneal@150 34 dataType: 'html',
bgneal@150 35 success: function (data, textStatus) {
bgneal@12 36 input.val('');
bgneal@12 37 if (data != '') {
bgneal@272 38 addShout(data);
bgneal@12 39 }
bgneal@12 40 submit.removeAttr('disabled');
bgneal@12 41 },
bgneal@150 42 error: function (xhr, textStatus, ex) {
bgneal@150 43 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
bgneal@150 44 xhr.responseText);
bgneal@150 45 }
bgneal@150 46 });
bgneal@12 47 return false;
bgneal@12 48 });
bgneal@12 49 var smilies_loaded = false;
bgneal@12 50 var smiley_frame = $('#shoutbox-smiley-frame');
bgneal@12 51 $('#shoutbox-smilies').click(function () {
bgneal@12 52 smiley_frame.toggle();
bgneal@12 53 if (!smilies_loaded) {
bgneal@12 54 smiley_frame.load('/smiley/farm/', function () {
bgneal@12 55 $('#shoutbox-busy-icon').hide();
bgneal@123 56 var txt = $("#shoutbox-smiley-input")[0];
bgneal@123 57 $('#shoutbox-smiley-frame img').click(function() {
bgneal@123 58 txt.value += ' ' + this.alt + ' ';
bgneal@123 59 txt.focus();
bgneal@123 60 });
bgneal@12 61 smilies_loaded = true;
bgneal@12 62 });
bgneal@12 63 }
bgneal@12 64 });
bgneal@12 65 });