Team:Newcastle/script/javascript.js

From 2013.igem.org

(Difference between revisions)
Line 12: Line 12:
var mode = "temp";
var mode = "temp";
 +
 +
var tocLeft = "";
 +
 +
var tocTopPerm = "";
$(function(){
$(function(){
Line 93: Line 97:
     // Check that you're not on the calendar and that you're not in Compatibility View
     // Check that you're not on the calendar and that you're not in Compatibility View
     if(url[url.length - 1] != "calendar")// && mode != "Compatibility View")
     if(url[url.length - 1] != "calendar")// && mode != "Compatibility View")
 +
    {
         ParsePage(location.hash);
         ParsePage(location.hash);
 +
   
 +
        $(window).scroll( function(e){
 +
           
 +
            var windowTop = $(window).scrollTop();
 +
            var tocTop = $('#toc').offset().top;
 +
            var contentTop = $('#page_content').offset().top - 10;
 +
            //alert(windowTop);
 +
           
 +
            if(windowTop > contentTop)
 +
            {
 +
                $('#toc').css({'position': 'fixed',
 +
                              'top': '5px',
 +
                              'left':tocLeft});
 +
            } else
 +
            {
 +
                $('#toc').css({'position': 'relative',
 +
                              'top': '0px',
 +
                              'left': '0px'});
 +
            }
 +
        });
 +
    }
      
      
     $('.top_menu li').hover(function(){
     $('.top_menu li').hover(function(){
Line 132: Line 158:
         });
         });
     }*/
     }*/
-
   
 
-
    var tocLeft = $('#toc').offset().left - 10;
 
-
    alert(tocLeft);
 
-
    var tocTopPerm = $('#toc').offset().top - $(window).scrollTop();
 
-
   
 
-
    $(window).scroll( function(e){
 
-
       
 
-
        var windowTop = $(window).scrollTop();
 
-
        var tocTop = $('#toc').offset().top;
 
-
        var contentTop = $('#page_content').offset().top - 10;
 
-
        //alert(windowTop);
 
-
       
 
-
        if(windowTop > contentTop)
 
-
        {
 
-
            $('#toc').css({'position': 'fixed',
 
-
                          'top': '5px',
 
-
                          'left':tocLeft});
 
-
        } else
 
-
        {
 
-
            $('#toc').css({'position': 'relative',
 
-
                          'top': '0px',
 
-
                          'left': '0px'});
 
-
        }
 
-
    });
 
});
});
Line 163: Line 165:
     $('#toc').nextUntil('#logos').addClass("temp_for_wrap");
     $('#toc').nextUntil('#logos').addClass("temp_for_wrap");
     $('.temp_for_wrap').wrapAll('<div id="page_content">');
     $('.temp_for_wrap').wrapAll('<div id="page_content">');
 +
   
 +
    tocLeft = $('#toc').offset().left - 10;
 +
    tocTopPerm = $('#toc').offset().top - $(window).scrollTop();
}
}

Revision as of 20:09, 1 October 2013

var toggleSpeed = 150;

var current_display = 'main';

var cur_main_display = 1;

var leaveFeedOpen = false;

var firstTimeOpened = true;

var cur_content = "";

var mode = "temp";

var tocLeft = "";

var tocTopPerm = "";

$(function(){

   //alert(msg);
   /*
   var loop1,
   c1 = 0;
   var loop2,
   c2 = 0;
   var loop3,
   c3 = 0;
   var loop4,
   c4 = 0;
   /*
   $('.box_2').on('mouseenter mouseleave', function( e ){
      if( e.type=='mouseleave' ){
        clearInterval( loop1 );
      }else{
        loop1 = setInterval(function(){        
           $('.box_2 .slice').css({transform: "rotate("+ ( (++c1) % 360 ) +"deg)"});                
        },30);   
      }
   });
   
   $('.box_3').on('mouseenter mouseleave', function( e ){
      if( e.type=='mouseleave' ){
        clearInterval( loop2 );
      }else{
        loop2 = setInterval(function(){        
           $('.box_3 .slice').css({transform: "rotate("+ ( (++c2 * -1) % 360 ) +"deg)"});                
        },30);   
      }
   });
   
   $('.box_4').on('mouseenter mouseleave', function( e ){
      if( e.type=='mouseleave' ){
        clearInterval( loop3 );
      }else{
        loop3 = setInterval(function(){        
           $('.box_4 .slice').css({transform: "rotate("+ ( (++c3 * 1) % 360 ) +"deg)"});                
        },30);   
      }
   });
   
   $('.box_5').on('mouseenter mouseleave', function( e ){
      if( e.type=='mouseleave' ){
        clearInterval( loop4 );
      }else{
        loop4 = setInterval(function(){        
           $('.box_5 .slice').css({transform: "rotate("+ ( (++c4 * -1) % 360 ) +"deg)"});                
        },30);   
      }
   });
   */
   /*
   var agentStr = navigator.userAgent;
   if (agentStr.indexOf("Trident/5.0") > -1) {
       if (agentStr.indexOf("MSIE 7.0") > -1)
           mode = "Compatibility View";
       else
           mode = "IE9";
   }
   else if (agentStr.indexOf("Trident/4.0") > -1) {
       if (agentStr.indexOf("MSIE 7.0") > -1)
           mode = "Compatibility View";
       else
           mode = "IE8";
   }
   else
       mode = "IE7";
   */
   // Code for organising pages into viewable
   
   // Strip the hash
   var href = (location.href).split("#");
   
   // Split the components
   var url = href[0].split("/");
   
   // Check that you're not on the calendar and that you're not in Compatibility View
   if(url[url.length - 1] != "calendar")// && mode != "Compatibility View")
   {
       ParsePage(location.hash);
   
       $(window).scroll( function(e){
           
           var windowTop = $(window).scrollTop();
           var tocTop = $('#toc').offset().top;
           var contentTop = $('#page_content').offset().top - 10;
           //alert(windowTop);
           
           if(windowTop > contentTop)
           {
               $('#toc').css({'position': 'fixed',
                              'top': '5px',
                             'left':tocLeft});
           } else
           {
               $('#toc').css({'position': 'relative',
                              'top': '0px',
                             'left': '0px'});
           }
       });
   }
   
   $('.top_menu li').hover(function(){
       $(this).find('ul').slideDown(toggleSpeed);
   }, function(){
       $(this).find('ul').slideUp(toggleSpeed);
   });
   
   $('#image_display .proj_box, #image_display .image_box').hover(function(){
       $(this).find('.display_image').hide();
       $(this).find('.under_text').show();
   }, function(){
       $(this).find('.display_image').show();
       if(!($(this).hasClass('box_1')))
           $(this).find('.under_text').hide();
   });
   
   // Event handlers for closing the pop up box. Individual actions taken by a page must be created in that page's JQuery
   $('#pop_up #pop_up_close').click(function(){
       $('#pop_up').fadeOut();
   });
   
   $('#pop_up #pop_up_underlay').click(function(){
       $('#pop_up').fadeOut();
   });
   /*
   if(mode != "Compatibility View")
   {
       $('.toclevel-2').click(function(){
           
           var href = $(this).children('a').attr('href');
           
           $('#toc').find('a[href="' + cur_content + '"]').toggleClass('active');
           $('#bodyContent').find(cur_content + '_section').hide();
           $('#bodyContent').find(href + '_section').show();
           
           cur_content = href;
       });
   }*/

});

function ParsePage(hash) {

//('
').insertAfter('#toc');
   $('#toc').nextUntil('#logos').addClass("temp_for_wrap");
$('.temp_for_wrap').wrapAll('
');
   tocLeft = $('#toc').offset().left - 10;
   tocTopPerm = $('#toc').offset().top - $(window).scrollTop();
}