- // Global vars
- var timerDuration = 4000;
- var timerResumeDuration = timerDuration * 3;
- var timer = undefined;
- var pagerLock = false;
- var globeContent = $(".globe, #points-wrapper"); // what gets rotated
- var ie_rotation = 0;
- // Document ready
- $(document).ready(function(){
- // Pre-stuff
- $('.point > .icon > .bubble').hide();
- $('#points-wrapper div:eq(0)').addClass('active').find('.bubble').fadeIn(800);
- autoRotate();
- // Globe arrows
- $('nav#globe li').click(function() {
- if (globeContent.is(':animated')) {
- console.log("In process of animating.");
- return false;
- }
- clearTimeout(timer);
- timerDuration = undefined; // uncomment this line to permanently stop rotation on arrow click
- pagerLock = true;
- if ($(this).hasClass('ccw')) {
- rotateGlobe(true, true);
- }
- else {
- rotateGlobe(false, true);
- }
- });
- // Inner scenes
- $('.point.active').live('click', function() {
- clearTimeout(timer);
- timerDuration = undefined;
- currentID = $(this).attr('id');
- $('#points-wrapper .point, .bubble').css({opacity:"0"});
- $('nav#globe').css({opacity:"0"});
- $('#scene-wrapper').css({zIndex:"1005"}).find('#scene-' + currentID).fadeIn(800).removeClass('exit').addClass('active');
- });
- $('.scene .back').live('click', function() {
- $(this).parent('.scene').removeClass('active').addClass('exit').delay(400).fadeOut(500, function() {
- $('#points-wrapper .point, #points-wrapper .point .bubble').css({opacity:"1"});
- $('nav#globe').css({opacity:"1"});
- $('#scene-wrapper').css({zIndex:"-1"});
- });
- return false;
- });
- });
- // Functions
- function autoRotate(overrideDuration) {
- if (overrideDuration !== undefined) {
- timer = setTimeout(function(){
- rotateGlobe(); //anonymous function because setTimeout tries to pass an arguement
- }, overrideDuration);
- }
- else {
- timer = setTimeout(function(){
- rotateGlobe(); //anonymous function because setTimeout tries to pass an arguement
- }, timerDuration);
- }
- }
- function rotateGlobe(ccw, delayRotate) {
- if (ccw == undefined) {
- ccw = false;
- }
- if (delayRotate == undefined) {
- delayRotate = false;
- }
- var active = $('#points-wrapper div.active');
- active.fadeIn(400, function() {
- $(this).removeClass('active').find('.bubble').fadeOut(400);
- var next;
- if (ccw) {
- next = $(this).prev();
- if (next.length == 0) {
- next = $(this).parent('div').find('div.point:last');
- }
- globeContent.animate({rotate: '+=51.429deg'}, 100, function() {});
- }
- else {
- next = $(this).next();
- if (next.length == 0) {
- next = $(this).parent('div').find('div.point:first');
- }
- globeContent.animate({rotate: '-=51.429deg'}, 100, function() {});
- }
- next.addClass('active').fadeIn(400, function(){
- next.find('.bubble').delay(470).addClass('active').fadeIn(200);
- if (timerDuration !== undefined) {
- if (delayRotate) {
- autoRotate(timerResumeDuration);
- }
- else {
- autoRotate();
- }
- }
- pagerLock = false;
- });
- });
- }