Team:Newcastle/script/javascript.js

From 2013.igem.org

(Difference between revisions)
 
(16 intermediate revisions not shown)
Line 1: Line 1:
var toggleSpeed = 150;
var toggleSpeed = 150;
-
var msg = "~~MESSAGE FROM MATT (Updates)~~\n\n\nUpdate:22/05/2013 (05:00)\nAdded another display type, if you click \"Change Display\" at the top of the page you should see the display underneath the image carousel change.\n\nUpdate:21/05/2013 (22:00)\nAdded in a main display page, the interactive elements you see on this page would generaly only be used on the front page of the wiki, but of course we can use them where-ever we want. Colors can be made different instead of all the blocks being the same very easily as well.\nThe twitter feed bug has been fixed and should now work perfectly :)\n\nUpdate:20/05/2013 (04:30)\nThe twitter feed is currently linked to my account but this can easily be changed. I think having a twitter will be a good tool to use as marketing.\nThe drop down functionality on tweets is also a little buggy but I'll sort it out before the meeting on wednesday hopefully.";
+
 
var current_display = 'main';
var current_display = 'main';
Line 12: Line 12:
var mode = "temp";
var mode = "temp";
 +
 +
var tocLeft = "";
 +
 +
var tocTopPerm = "";
$(function(){
$(function(){
      
      
     //alert(msg);
     //alert(msg);
-
     //YOUTUBER.loadUpdates();
+
     /*
-
   
+
     var loop1,        
-
     var loop1,
+
     c1 = 0;
     c1 = 0;
     var loop2,
     var loop2,
Line 65: Line 68:
         },30);   
         },30);   
       }
       }
-
     });*/
+
     });
-
      
+
    */
 +
     /*
     var agentStr = navigator.userAgent;
     var agentStr = navigator.userAgent;
     if (agentStr.indexOf("Trident/5.0") > -1) {
     if (agentStr.indexOf("Trident/5.0") > -1) {
Line 82: Line 86:
     else
     else
         mode = "IE7";
         mode = "IE7";
-
      
+
     */
     // Code for organising pages into viewable
     // Code for organising pages into viewable
      
      
Line 92: Line 96:
      
      
     // 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" && $('#toc').length && url[url.length - 1] != "protocols" )// && 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 99: Line 125:
     }, function(){
     }, function(){
         $(this).find('ul').slideUp(toggleSpeed);
         $(this).find('ul').slideUp(toggleSpeed);
-
    });
 
-
   
 
-
    $('#twitter_feed').hover(function(){
 
-
        $('#tweet_case').slideDown(toggleSpeed);
 
-
    }, function(){
 
-
        $('#tweet_case').slideUp(toggleSpeed);
 
     });
     });
      
      
Line 124: Line 144:
         $('#pop_up').fadeOut();
         $('#pop_up').fadeOut();
     });
     });
-
      
+
     /*
     if(mode != "Compatibility View")
     if(mode != "Compatibility View")
     {
     {
Line 137: Line 157:
             cur_content = href;
             cur_content = href;
         });
         });
-
     }
+
     }*/
-
   
+
-
    var tocLeft = $('#toc').offset().left - 10;
+
-
    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 168: 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();
 +
   
 +
    $('#toc .toclevel-1').append('<li class="toclevel-2 tocsection-6"><a href="#"><span class="tocnumber">1.5</span> <span class="toctext">Return to Top</span></a></li>');
}
}

Latest revision as of 17:25, 3 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" && $('#toc').length && url[url.length - 1] != "protocols" )// && 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();
   
$('#toc .toclevel-1').append('
  • <a href="#">1.5 Return to Top</a></li>'); }