Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // set the height of the quote box to the tallest one
  2. var tallestQuote = 0;
  3. $('#home-players .quotes article').each(function() {
  4.     if ($(this).height() > tallestQuote) tallestQuote = $(this).outerHeight();
  5. }).css('position', 'absolute');
  6. $('#home-players .quotes').height(tallestQuote);
  7.  
  8. var previousAnimationRunning = false;
  9.  
  10. // make the quotes clickable
  11. $('#home-players ul.users li').click(function(e, auto) {
  12.         // check whether the click event was automated before checking whether the previous animation is running
  13.         if (auto && previousAnimationRunning) {
  14.         return false;
  15.     }
  16.  
  17.     previousAnimationRunning = true;
  18.  
  19.     // add the active class to the user
  20.     $(this).addClass('active').siblings().removeClass('active');
  21.  
  22.     if (!auto) startQuotes();
  23.  
  24.     // swap out the quote
  25.     var current = $(this).prevAll().length;
  26.     var $articles = $('#home-players .quotes article');
  27.     var $current = $articles.eq(current);
  28.     $current.siblings('article').velocity('fadeOut');
  29.     $current.velocity('fadeIn', {
  30.         complete: function() {
  31.             previousAnimationRunning = false;
  32.         }
  33.     });
  34.  
  35.     // move the indicator
  36.     $('#home-players .quotes .indicator').velocity({
  37.         left: (59 + 172 * current)
  38.     });
  39.  
  40.     return false;
  41. });
  42.  
  43. // auto advance the quotes
  44. var quoteTimer = null;
  45. var startQuotes = function() {
  46.     clearInterval(quoteTimer);
  47.     quoteTimer = setInterval(function() {
  48.         var $users = $('#home-players ul.users li');
  49.         var $next = $users.filter('.active').next();
  50.         if ($next.length == 0) $next = $users.eq(0);
  51.         $next.trigger('click', [true]);
  52.     }, 7500);
  53. };
  54. $('#home-players .quotes').one('inview', startQuotes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement