Mercurial > public > sg101
comparison media/js/shoutbox.js @ 296:0eed8161ca39
Fixing #138. Shoutbox scroller breaks down if there aren't at least 2 things to scroll. Added some dummy shouts on the client side if the shout database is empty.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 09 Jan 2011 20:53:00 +0000 |
parents | 4557974db0e0 |
children |
comparison
equal
deleted
inserted
replaced
295:26fc9ac9a0eb | 296:0eed8161ca39 |
---|---|
1 $(document).ready(function() { | 1 $(document).ready(function() { |
2 | 2 |
3 var numShouts = $('#shoutbox-shout-container > p').size(); | 3 var numShouts = $('#shoutbox-shout-container > p').size(); |
4 var sbBox = $('#shoutbox-shout-container'); | |
5 | |
6 if (numShouts < 2) | |
7 { | |
8 sbBox.append('<p>Welcome to SurfGuitar101.com!</p>'); | |
9 ++numShouts; | |
10 } | |
11 if (numShouts < 2) | |
12 { | |
13 sbBox.append('<p>((((( More Reverb )))))</p>'); | |
14 ++numShouts; | |
15 } | |
16 | |
4 var sbCycleOpts = null; | 17 var sbCycleOpts = null; |
5 var sbCycle = $('#shoutbox-shout-container').cycle({ | 18 var sbCycle = sbBox.cycle({ |
6 fx: 'scrollUp', | 19 fx: 'scrollUp', |
7 timeout: 5000, | 20 timeout: 5000, |
8 pause: 1, | 21 pause: 1, |
9 next: '#shoutbox-next', | 22 next: '#shoutbox-next', |
10 prev: '#shoutbox-prev', | 23 prev: '#shoutbox-prev', |
14 } | 27 } |
15 }); | 28 }); |
16 function addShout(shout) { | 29 function addShout(shout) { |
17 ++numShouts; | 30 ++numShouts; |
18 sbCycleOpts.addSlide(shout); | 31 sbCycleOpts.addSlide(shout); |
19 $('#shoutbox-shout-container').cycle(numShouts - 1); | 32 sbBox.cycle(numShouts - 1); |
20 } | 33 } |
21 | 34 |
22 var submit = $('#shoutbox-submit'); | 35 var submit = $('#shoutbox-submit'); |
23 submit.click(function () { | 36 submit.click(function () { |
24 var input = $('#shoutbox-smiley-input'); | 37 var input = $('#shoutbox-smiley-input'); |