Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // set the height of the quote box to the tallest one
- var tallestQuote = 0;
- $('#home-players .quotes article').each(function() {
- if ($(this).height() > tallestQuote) tallestQuote = $(this).outerHeight();
- }).css('position', 'absolute');
- $('#home-players .quotes').height(tallestQuote);
- var previousAnimationRunning = false;
- // make the quotes clickable
- $('#home-players ul.users li').click(function(e, auto) {
- // check whether the click event was automated before checking whether the previous animation is running
- if (auto && previousAnimationRunning) {
- return false;
- }
- previousAnimationRunning = true;
- // add the active class to the user
- $(this).addClass('active').siblings().removeClass('active');
- if (!auto) startQuotes();
- // swap out the quote
- var current = $(this).prevAll().length;
- var $articles = $('#home-players .quotes article');
- var $current = $articles.eq(current);
- $current.siblings('article').velocity('fadeOut');
- $current.velocity('fadeIn', {
- complete: function() {
- previousAnimationRunning = false;
- }
- });
- // move the indicator
- $('#home-players .quotes .indicator').velocity({
- left: (59 + 172 * current)
- });
- return false;
- });
- // auto advance the quotes
- var quoteTimer = null;
- var startQuotes = function() {
- clearInterval(quoteTimer);
- quoteTimer = setInterval(function() {
- var $users = $('#home-players ul.users li');
- var $next = $users.filter('.active').next();
- if ($next.length == 0) $next = $users.eq(0);
- $next.trigger('click', [true]);
- }, 7500);
- };
- $('#home-players .quotes').one('inview', startQuotes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement