Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 3.20 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Global vars
  2. var timerDuration = 4000;
  3. var timerResumeDuration = timerDuration * 3;
  4. var timer = undefined;
  5. var pagerLock = false;
  6. var globeContent = $(".globe, #points-wrapper");        // what gets rotated
  7. var ie_rotation = 0;
  8.  
  9. // Document ready
  10. $(document).ready(function(){
  11.  
  12.   // Pre-stuff
  13.   $('.point > .icon > .bubble').hide();
  14.   $('#points-wrapper div:eq(0)').addClass('active').find('.bubble').fadeIn(800);
  15.  
  16.   autoRotate();
  17.  
  18.   // Globe arrows
  19.   $('nav#globe li').click(function() {
  20.     if (globeContent.is(':animated')) {
  21.       console.log("In process of animating.");
  22.       return false;
  23.     }
  24.    
  25.     clearTimeout(timer);
  26.     timerDuration = undefined;      // uncomment this line to permanently stop rotation on arrow click
  27.     pagerLock = true;
  28.     if ($(this).hasClass('ccw')) {
  29.       rotateGlobe(true, true);
  30.     }
  31.     else {
  32.       rotateGlobe(false, true);
  33.     }
  34.   });
  35.  
  36.   // Inner scenes
  37.   $('.point.active').live('click', function() {
  38.     clearTimeout(timer);
  39.     timerDuration = undefined;
  40.     currentID = $(this).attr('id');
  41.     $('#points-wrapper .point, .bubble').css({opacity:"0"});
  42.     $('nav#globe').css({opacity:"0"});
  43.     $('#scene-wrapper').css({zIndex:"1005"}).find('#scene-' + currentID).fadeIn(800).removeClass('exit').addClass('active');
  44.   });
  45.  
  46.   $('.scene .back').live('click', function() {
  47.     $(this).parent('.scene').removeClass('active').addClass('exit').delay(400).fadeOut(500, function() {
  48.       $('#points-wrapper .point, #points-wrapper .point .bubble').css({opacity:"1"});
  49.       $('nav#globe').css({opacity:"1"});
  50.       $('#scene-wrapper').css({zIndex:"-1"});
  51.     });
  52.     return false;
  53.   });
  54.  
  55. });
  56.  
  57. // Functions
  58. function autoRotate(overrideDuration) {
  59.   if (overrideDuration !== undefined) {
  60.     timer = setTimeout(function(){
  61.       rotateGlobe();      //anonymous function because setTimeout tries to pass an arguement
  62.     }, overrideDuration);
  63.   }
  64.   else {
  65.     timer = setTimeout(function(){
  66.       rotateGlobe();      //anonymous function because setTimeout tries to pass an arguement
  67.     }, timerDuration);
  68.   }
  69. }
  70.  
  71. function rotateGlobe(ccw, delayRotate) {
  72.   if (ccw == undefined) {
  73.     ccw = false;
  74.   }
  75.   if (delayRotate == undefined) {
  76.     delayRotate = false;
  77.   }
  78.  
  79.   var active = $('#points-wrapper div.active');
  80.  
  81.   active.fadeIn(400, function() {
  82.  
  83.     $(this).removeClass('active').find('.bubble').fadeOut(400);
  84.  
  85.     var next;
  86.  
  87.     if (ccw) {
  88.       next = $(this).prev();
  89.       if (next.length == 0) {
  90.         next = $(this).parent('div').find('div.point:last');
  91.       }
  92.  
  93.       globeContent.animate({rotate: '+=51.429deg'}, 100, function() {});
  94.     }
  95.     else {
  96.       next = $(this).next();
  97.       if (next.length == 0) {
  98.         next = $(this).parent('div').find('div.point:first');
  99.       }
  100.  
  101.       globeContent.animate({rotate: '-=51.429deg'}, 100, function() {});
  102.     }
  103.  
  104.     next.addClass('active').fadeIn(400, function(){
  105.       next.find('.bubble').delay(470).addClass('active').fadeIn(200);
  106.       if (timerDuration !== undefined) {
  107.         if (delayRotate) {
  108.           autoRotate(timerResumeDuration);
  109.         }
  110.         else {
  111.           autoRotate();
  112.         }
  113.       }
  114.       pagerLock = false;
  115.     });
  116.   });
  117. }