Team:Newcastle/script/javascript.js

From 2013.igem.org

(Difference between revisions)
Line 172: Line 172:
          
          
         var windowTop = $(window).scrollTop();
         var windowTop = $(window).scrollTop();
-
          
+
         alert(windowTop);
         if(windowTop > tocTop)
         if(windowTop > tocTop)
         {
         {

Revision as of 18:36, 1 October 2013

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 cur_main_display = 1;

var leaveFeedOpen = false;

var firstTimeOpened = true;

var cur_content = "";

var mode = "temp";

$(function(){

   //alert(msg);
   //YOUTUBER.loadUpdates();

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);

   $('.top_menu li').hover(function(){
       $(this).find('ul').slideDown(toggleSpeed);
   }, function(){
       $(this).find('ul').slideUp(toggleSpeed);
   });
   
   $('#twitter_feed').hover(function(){
       $('#tweet_case').slideDown(toggleSpeed);
   }, function(){
       $('#tweet_case').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();

   });
   /*
   $('#rss_feed').hover(function(){
       $(this).animate({marginLeft:"-150px"}, toggleSpeed, 'easeOutSine');
       
       if(firstTimeOpened)
       {
           $('#rss_feed_tooltip').show();
           //firstTimeOpened = false;
       }
   }, function(){
       if(!leaveFeedOpen)
           $(this).animate({marginLeft:"-30px"}, toggleSpeed, 'easeInSine');
       
       if(firstTimeOpened)
       {
           $('#rss_feed_tooltip').hide();
           //$.cookie('firstTimeOpened', 'false');
       }
   });
   
   $('#rss_feed').click(function(){
       if(leaveFeedOpen)
           leaveFeedOpen = false;
       else
           leaveFeedOpen = true;
   });*/
   // 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;

setTocHeight(); }); }

   var tocTop = $('#toc').offset().top;
   $(window).scroll( function(e){
       
       var windowTop = $(window).scrollTop();
       alert(windowTop);
       if(windowTop > tocTop)
       {
           alert("Hello World");
           //$('#tocTop').css('position', 'absolute').css('top', '5px');
       }
   });

});

function ParsePage(hash) {

//('
').insertAfter('#toc');
   $('#toc').nextUntil('#logos').addClass("temp_for_wrap");
$('.temp_for_wrap').wrapAll('
'); //$('
').insertBefore('#logos');
   /*

var numSections = parseInt($('.toclevel-2').length); var logos = $('#bodyContent').find($('#logos')).html();

var logosExists = $('#bodyContent').find($('#logos')).length;

$('#bodyContent').find($('#logos')).remove();

if(numSections > 1) { var topLevelTag = $('#bodyContent').find($('.toclevel-2').children('a').attr('href')).parent().prop("tagName"); var topLevelTag = 'h2';

$('#bodyContent').children('.printfooter').before('<' + topLevelTag + ' id="temp_h2">Temp</' + topLevelTag + '>');

for(var i = 0; i < numSections; i++) { var currentID = $('.toclevel-2').eq(i).children('a').attr('href');

var currentTitle = $('#bodyContent').find(currentID);

var currentClass = currentID.replace("#","");

$(currentID).removeAttr('id');

$(currentTitle).parent().nextUntil(topLevelTag).andSelf().addClass(currentClass);

$("." + currentClass).wrapAll('
');

//$("." + currentClass).removeClass(currentClass);

if(hash == "") { if(i > 0) $('#bodyContent').find(currentID + '_section').hide(); else cur_content = currentID; } else { if(hash == currentID) cur_content = currentID; else $('#bodyContent').find(currentID + '_section').hide(); } }

$('#bodyContent').find('#temp_h2').remove(); } else { $('#bodyContent').find('#toc').hide(); }

if($('#toc').length) { //alert($('#bodyContent').find('#toc').html());

$('#toc').find('#toctitle h2').html($('.toclevel-1').find('.toctext').first().text() + '
');

$('.toclevel-1').find('.toctext').first().hide();

$('' + $('#bodyContent').find('#toc').html() + '
').insertAfter($('#bodyContent').find('h1').first());

$('#bodyContent').find('#toc').first().remove(); }

//$('.printfooter').insertBefore(logos);

if(logosExists) $('
' + logos + '
').insertBefore($('.printfooter')); $('
').insertAfter($('#bodyContent').find('h1').first());

setTocHeight();

   */

}

function setTocHeight() { if(mode != "Compatibility View") { $('#toc').find('a[href="' + cur_content + '"]').toggleClass('active');

var count = 0;

while((count < 5)) { $('#toc').height($(cur_content + '_section').height() + 30);

count ++; } }

}