Mercurial > public > sg101
diff media/js/shoutbox.js @ 272:4557974db0e0
For #114, committing a new shoutbox based on the jquery cycle plugin for user feedback.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 26 Sep 2010 19:08:31 +0000 |
parents | b43e1288ff80 |
children | 0eed8161ca39 |
line wrap: on
line diff
--- a/media/js/shoutbox.js Sun Sep 26 17:42:00 2010 +0000 +++ b/media/js/shoutbox.js Sun Sep 26 19:08:31 2010 +0000 @@ -1,4 +1,24 @@ $(document).ready(function() { + + var numShouts = $('#shoutbox-shout-container > p').size(); + var sbCycleOpts = null; + var sbCycle = $('#shoutbox-shout-container').cycle({ + fx: 'scrollUp', + timeout: 5000, + pause: 1, + next: '#shoutbox-next', + prev: '#shoutbox-prev', + before: function(curr, next, opts) { + if (!opts.addSlide || sbCycleOpts) return; + sbCycleOpts = opts; + } + }); + function addShout(shout) { + ++numShouts; + sbCycleOpts.addSlide(shout); + $('#shoutbox-shout-container').cycle(numShouts - 1); + } + var submit = $('#shoutbox-submit'); submit.click(function () { var input = $('#shoutbox-smiley-input'); @@ -15,8 +35,7 @@ success: function (data, textStatus) { input.val(''); if (data != '') { - $('#shoutbox-shout-container').prepend(data); - $('#shoutbox-shout-container p:first').fadeIn(2500); + addShout(data); } submit.removeAttr('disabled'); },