Template:WUR script.js

From 2012.igem.org

(Difference between revisions)
 
(85 intermediate revisions not shown)
Line 1: Line 1:
-
var jQueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
+
/* START SCRIPT */
-
//var cssUrl = "http://www.the-falcons.nl/igem2/style.css";
+
 
var cssUrl = "https://2012.igem.org/Template:WUR_style.css?action=raw&ctype=text/css";
var cssUrl = "https://2012.igem.org/Template:WUR_style.css?action=raw&ctype=text/css";
var nivoJsUrl = 'https://2012.igem.org/Template:WUR_nivo.js?action=raw&ctype=text/javascript';
var nivoJsUrl = 'https://2012.igem.org/Template:WUR_nivo.js?action=raw&ctype=text/javascript';
Line 8: Line 8:
var headerImgUrl = "";
var headerImgUrl = "";
-
var jQueryScriptOutputted = false;
+
jq18(document).ready(function($){
-
 
+
-
function initJQuery() {
+
-
    //if the jQuery object isn't available
+
// CSS
-
    if (typeof(jQuery) == 'undefined') {
+
$("<link/>", {
-
 
+
rel: "stylesheet",
-
        if (! jQueryScriptOutputted) {
+
type: "text/css",
-
            //only output the script once..
+
href: cssUrl
-
            jQueryScriptOutputted = true;
+
}).appendTo("head");
-
           
+
-
            //output the script (load it from google api)
+
// Sliders
-
            document.write("<script type=\"text/javascript\" src=\"" + jQueryUrl + "\"></script>");
+
$('.detection_slider').nivoSlider({
-
 
+
effect: 'fade',
-
        }
+
directionNav: true,
-
        setTimeout("initJQuery()", 50);
+
controlNav: false,
-
    } else {
+
pauseTime: 4000,
-
        $(function() {
+
animSpeed: 500
-
jQuery(document).ready(function(){
+
});
-
+
-
// CSS
+
// Move menu
-
$("<link/>", {
+
var menu = $('#navContainer');
-
rel: "stylesheet",
+
$('#navContainer').remove();
-
type: "text/css",
+
$('#content').prepend(menu);
-
href: cssUrl
+
-
}).appendTo("head");
+
// Move header
-
+
var header = $('#header_wrapper');
-
/*
+
$('#header_wrapper').remove();
-
// Slider
+
$('#content').prepend(header);
-
$("<link/>", {
+
-
rel: "stylesheet",
+
// Decorate menu
-
type: "text/css",
+
function decorateMenu(el, i) {
-
href: nivoCssUrl
+
switch(i) {
-
}).appendTo("head");
+
case 1: el.addClass('ulc1'); i += 1;
-
$.getScript(nivoJsUrl, function(){
+
break;
-
//http://nivo.dev7studios.com/support/jquery-plugin-usage/
+
-
$('#header_slider').nivoSlider({
+
case 2: el.addClass('ulc2'); i += 1;
-
effect: 'fade',
+
break;
-
directionNav: false,
+
-
controlNav: false,
+
case 3: i = 1;
-
pauseTime: 5500,
+
break;
-
animSpeed: 1000
+
-
});
+
default: i += 1;
-
});
+
}
-
*/
+
return i;
-
+
-
// Move menu
+
-
var menu = $('#navContainer');
+
-
$('#navContainer').remove();
+
-
$('#content').prepend(menu);
+
-
+
-
// Move header
+
-
var header = $('#header_wrapper');
+
-
$('#header_wrapper').remove();
+
-
$('#content').prepend(header);
+
-
+
-
// Decorate menu
+
-
function decorateMenu(el, i) {
+
-
switch(i) {
+
-
case 1: el.addClass('ulc1'); i += 1;
+
-
break;
+
-
+
-
case 2: el.addClass('ulc2'); i += 1;
+
-
break;
+
-
+
-
case 3: i = 1;
+
-
break;
+
-
+
-
default: i += 1;
+
-
}
+
-
return i;
+
-
}
+
-
var i = 0;
+
-
var ii = 0;
+
-
menu.find('li').each(function(){
+
-
i = decorateMenu($(this),i);
+
-
ii = $(this).find('ul').find('li').each(function(){decorateMenu($(this),ii);});
+
-
});
+
-
+
-
// Remove title attributes from the menu.
+
-
// Though this is a bad practice, the design advantage weighted
+
-
// heavier than the few optically impaired people who visit the
+
-
// website.
+
-
menu.find('[title]').removeAttr('title');
+
-
+
-
// Google Analytics
+
-
var ga_script = "\
+
-
<script type=\"text/javascript\">\
+
-
  var _gaq = _gaq || [];\
+
-
  _gaq.push(['_setAccount', 'UA-33423824-1']);\
+
-
  _gaq.push(['_trackPageview']);\
+
-
  (function() {\
+
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\
+
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\
+
-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\
+
-
  })();\
+
-
</script>";
+
-
$('head').append(ga_script);
+
-
+
-
// Move the Footer
+
-
$('#contentfooter').appendTo('#content');
+
-
+
-
$('.bigbutton').hover(function(){
+
-
$(this).find('img').animate({
+
-
'margin-top': '-175px'
+
-
},'fast');
+
-
},function(){
+
-
$(this).find('img').animate({
+
-
'margin-top': '0px'
+
-
},'fast');
+
-
});
+
-
+
-
/*
+
-
// Effect on the home buttons
+
-
$('.homebutton').hover(function(){
+
-
$(this).animate({
+
-
  height: "300",
+
-
  width: "480",
+
-
  left: "-=90",
+
-
  top: "-=50",
+
-
  'border-radius': '5px'
+
-
}, "fast");
+
-
},function(){
+
-
$(this).animate({
+
-
height: "200",
+
-
width: "320",
+
-
left: "+=90",
+
-
  top: "+=50",
+
-
  'border-radius': '0px'
+
-
}, "fast");
+
-
});
+
-
*/
+
-
+
-
// If an anchor-link was pressed, make sure the scrolling was done correctly.
+
-
if(location.hash) {
+
-
var sId = location.hash.substr(1);
+
-
var sEl = document.getElementById(sId);
+
-
var sJQ = $(sEl);
+
-
+
-
setTimeout(function(){
+
-
$(document).scrollTop(sJQ.offset().top);
+
-
}, 250);
+
-
+
-
}
+
-
+
-
// Fix prefixes for CSS3 styles
+
-
$.getScript(prefixfreeUrl, function(){});
+
-
+
-
// Animate the project overview
+
-
$('#poPnas, #poVLPs, #poOutside, #poInside, #poApplications').hide();
+
-
$('#poPnas').fadeIn(500, function(){
+
-
$('#poVLPs').fadeIn(500, function(){
+
-
$('#poOutside').fadeIn(500, function(){
+
-
$('#poInside').fadeIn(500, function(){
+
-
$('#poApplications').fadeIn(500, function(){});
+
-
});
+
-
});
+
-
});
+
-
});
+
-
+
-
// Click actions for the project overview
+
-
function poLoad(url) {
+
-
$('#poTextClose').fadeOut();
+
-
$('#poText').slideUp().fadeOut('fast', function(){
+
-
$('#poLoading').fadeIn('fast');
+
-
$('#poText').load(url, function(){
+
-
$('#poLoading').fadeOut('fast');
+
-
$('#poTextClose').fadeIn();
+
-
$(this).fadeIn().slideDown();
+
-
});
+
-
});
+
-
}
+
-
$('#poTextClose').click(function() {
+
-
$('#poText').slideUp().fadeOut();
+
-
$('#poTextClose').fadeOut();
+
-
});
+
-
$('#poPnas').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/Pnas_ProjectOverview?action=render'); });
+
-
$('#poVLPs').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/VLPs_ProjectOverview?action=render'); });
+
-
$('#poOutside').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/OutsideModification_ProjectOverview?action=render'); });
+
-
$('#poInside').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/InsideModification_ProjectOverview?action=render'); });
+
-
$('#poApplications').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/Applications_ProjectOverview?action=render'); });
+
-
+
-
+
-
+
-
// Achievements animation
+
-
$('.achievement').click(function(){
+
-
$(this).find('.achievement-desc').slideDown('fast');
+
-
});
+
-
$('.achievement').hover(function(){
+
-
//$(this).find('.achievement-desc').slideDown('fast');
+
-
},function(){
+
-
$(this).find('.achievement-desc').slideUp('fast');
+
-
});
+
-
+
-
// IE8 column correction
+
-
if($.browser.msie && parseInt($.browser.version,10) < 9) {
+
-
$('.col').css('width','296px');
+
-
}
+
-
+
-
// Team photos
+
-
$('#teamScatter').hover(function(){
+
-
$('#teamScatter > div.Hover').fadeIn();
+
-
},function(){
+
-
$('#teamScatter > div.Hover').fadeOut();
+
-
});
+
-
$('#teamScatter').mousemove(function(e){
+
-
$('#teamScatter > div.Hover').css({
+
-
'left': e.pageX - $(this).offset().left - 100,
+
-
'top': e.pageY - $(this).offset().top + 20
+
-
});
+
-
});
+
-
$('#teamScatter area').mouseover(function(){
+
-
$('#teamScatter > div.Hover').text($(this).attr('alt'));
+
-
});
+
-
+
-
});
+
-
});
+
}
}
-
}
+
var i = 0;
 +
var ii = 0;
 +
menu.find('li').each(function(){
 +
i = decorateMenu($(this),i);
 +
ii = $(this).find('ul').find('li').each(function(){decorateMenu($(this),ii);});
 +
});
 +
 +
// Remove title attributes from the menu.
 +
// Though this is a bad practice, the design advantage weighted
 +
// heavier than the few optically impaired people who visit the
 +
// website.
 +
menu.find('[title]').removeAttr('title');
 +
 +
// Google Analytics
 +
var ga_script = "\
 +
<script type=\"text/javascript\">\
 +
  var _gaq = _gaq || [];\
 +
  _gaq.push(['_setAccount', 'UA-33423824-1']);\
 +
  _gaq.push(['_trackPageview']);\
 +
  (function() {\
 +
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\
 +
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\
 +
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\
 +
  })();\
 +
</script>";
 +
$('head').append(ga_script);
 +
 +
// Move the Footer
 +
$('#contentfooter').appendTo('#content');
 +
 +
$('.bigbutton').hover(function(){
 +
$(this).find('img').animate({
 +
'margin-top': '-175px'
 +
},'fast');
 +
},function(){
 +
$(this).find('img').animate({
 +
'margin-top': '0px'
 +
},'fast');
 +
});
 +
 +
// If an anchor-link was pressed, make sure the scrolling was done correctly.
 +
if(location.hash) {
 +
var sId = location.hash.substr(1);
 +
var sEl = document.getElementById(sId);
 +
var sJQ = $(sEl);
 +
 +
setTimeout(function(){
 +
$(document).scrollTop(sJQ.offset().top);
 +
}, 250);
 +
 +
}
 +
 +
// Back to top button
 +
$('#thisisthetop').prependTo('body');
 +
$('#gototop').appendTo('body');
 +
 +
 +
// Fix prefixes for CSS3 styles
 +
$.getScript(prefixfreeUrl, function(){});
 +
 +
// Achievements animation
 +
$('.achievement').click(function(){
 +
$(this).find('.achievement-desc').slideDown('fast');
 +
});
 +
$('.achievement').hover(function(){
 +
//$(this).find('.achievement-desc').slideDown('fast');
 +
},function(){
 +
$(this).find('.achievement-desc').slideUp('fast');
 +
});
 +
 +
// IE8 column correction
 +
if($.browser.msie && parseInt($.browser.version,10) < 9) {
 +
$('.col').css('width','296px');
 +
$('.twocol').css('width','617px');
 +
}
 +
 +
// Fancybox
 +
$('.fancybox').fancybox();
 +
$('.iframefancybox').fancybox({type: 'iframe'});
 +
 +
// Map highlights:
 +
$('img.highlight').maphilight({
 +
fill: true,
 +
fillColor: 'ffffff',
 +
fillOpacity: 0.2,
 +
stroke: true,
 +
strokeColor: '000000',
 +
strokeOpacity: 0.5,
 +
strokeWidth: 1,
 +
fade: true,
 +
alwaysOn: false,
 +
neverOn: false,
 +
groupBy: false,
 +
wrapClass: true,
 +
shadow: false,
 +
shadowX: 0,
 +
shadowY: 0,
 +
shadowRadius: 6,
 +
shadowColor: '000000',
 +
shadowOpacity: 0.8,
 +
shadowPosition: 'outside',
 +
shadowFrom: false
 +
});
 +
$('img.highlight2').maphilight({
 +
fill: true,
 +
fillColor: 'ffffff',
 +
fillOpacity: 0.2,
 +
stroke: false,
 +
strokeColor: '000000',
 +
strokeOpacity: 0.5,
 +
strokeWidth: 1,
 +
fade: true,
 +
alwaysOn: false,
 +
neverOn: false,
 +
groupBy: false,
 +
wrapClass: true,
 +
shadow: false,
 +
shadowX: 0,
 +
shadowY: 0,
 +
shadowRadius: 6,
 +
shadowColor: '000000',
 +
shadowOpacity: 0.8,
 +
shadowPosition: 'outside',
 +
shadowFrom: false
 +
});
 +
$('img.highlight3').maphilight({
 +
fill: true,
 +
fillColor: 'ffffff',
 +
fillOpacity: 0.4,
 +
stroke: false,
 +
strokeColor: '000000',
 +
strokeOpacity: 0.5,
 +
strokeWidth: 1,
 +
fade: true,
 +
alwaysOn: false,
 +
neverOn: false,
 +
groupBy: false,
 +
wrapClass: true,
 +
shadow: false,
 +
shadowX: 0,
 +
shadowY: 0,
 +
shadowRadius: 6,
 +
shadowColor: '000000',
 +
shadowOpacity: 0.8,
 +
shadowPosition: 'outside',
 +
shadowFrom: false
 +
});
 +
 +
// Project Overview
 +
$('#prOv > div.buttonbox').hover(function(){
 +
$('#prOvText').html($(this).find('.hiddentext').html())
 +
$('#prOvText').show();
 +
},function(){
 +
$('#prOvText').hide();
 +
});
 +
 +
});
 +
 
-
if(location.action!="render") {
+
$ = jq18;
-
initJQuery();
+
-
}
+

Latest revision as of 18:35, 26 October 2012

/* START SCRIPT */

var cssUrl = "https://2012.igem.org/Template:WUR_style.css?action=raw&ctype=text/css"; var nivoJsUrl = 'https://2012.igem.org/Template:WUR_nivo.js?action=raw&ctype=text/javascript'; var nivoCssUrl = "https://2012.igem.org/Template:WUR_nivo.css?action=raw&ctype=text/css"; var prefixfreeUrl = 'https://2012.igem.org/Template:WUR_prefixfree.js?action=raw&ctype=text/javascript';

var headerImgUrl = "";

jq18(document).ready(function($){

// CSS $("<link/>", { rel: "stylesheet", type: "text/css", href: cssUrl }).appendTo("head");

// Sliders $('.detection_slider').nivoSlider({ effect: 'fade', directionNav: true, controlNav: false, pauseTime: 4000, animSpeed: 500 });

// Move menu var menu = $('#navContainer'); $('#navContainer').remove(); $('#content').prepend(menu);

// Move header var header = $('#header_wrapper'); $('#header_wrapper').remove(); $('#content').prepend(header);

// Decorate menu function decorateMenu(el, i) { switch(i) { case 1: el.addClass('ulc1'); i += 1; break;

case 2: el.addClass('ulc2'); i += 1; break;

case 3: i = 1; break;

default: i += 1; } return i; } var i = 0; var ii = 0; menu.find('li').each(function(){ i = decorateMenu($(this),i); ii = $(this).find('ul').find('li').each(function(){decorateMenu($(this),ii);}); });

// Remove title attributes from the menu. // Though this is a bad practice, the design advantage weighted // heavier than the few optically impaired people who visit the // website. menu.find('[title]').removeAttr('title');

// Google Analytics var ga_script = "\ <script type=\"text/javascript\">\ var _gaq = _gaq || [];\ _gaq.push(['_setAccount', 'UA-33423824-1']);\ _gaq.push(['_trackPageview']);\ (function() {\ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\ })();\ </script>"; $('head').append(ga_script);

// Move the Footer $('#contentfooter').appendTo('#content');

$('.bigbutton').hover(function(){ $(this).find('img').animate({ 'margin-top': '-175px' },'fast'); },function(){ $(this).find('img').animate({ 'margin-top': '0px' },'fast'); });

// If an anchor-link was pressed, make sure the scrolling was done correctly. if(location.hash) { var sId = location.hash.substr(1); var sEl = document.getElementById(sId); var sJQ = $(sEl);

setTimeout(function(){ $(document).scrollTop(sJQ.offset().top); }, 250);

}

// Back to top button $('#thisisthetop').prependTo('body'); $('#gototop').appendTo('body');


// Fix prefixes for CSS3 styles $.getScript(prefixfreeUrl, function(){});

// Achievements animation $('.achievement').click(function(){ $(this).find('.achievement-desc').slideDown('fast'); }); $('.achievement').hover(function(){ //$(this).find('.achievement-desc').slideDown('fast'); },function(){ $(this).find('.achievement-desc').slideUp('fast'); });

// IE8 column correction if($.browser.msie && parseInt($.browser.version,10) < 9) { $('.col').css('width','296px'); $('.twocol').css('width','617px'); }

// Fancybox $('.fancybox').fancybox(); $('.iframefancybox').fancybox({type: 'iframe'});

// Map highlights: $('img.highlight').maphilight({ fill: true, fillColor: 'ffffff', fillOpacity: 0.2, stroke: true, strokeColor: '000000', strokeOpacity: 0.5, strokeWidth: 1, fade: true, alwaysOn: false, neverOn: false, groupBy: false, wrapClass: true, shadow: false, shadowX: 0, shadowY: 0, shadowRadius: 6, shadowColor: '000000', shadowOpacity: 0.8, shadowPosition: 'outside', shadowFrom: false }); $('img.highlight2').maphilight({ fill: true, fillColor: 'ffffff', fillOpacity: 0.2, stroke: false, strokeColor: '000000', strokeOpacity: 0.5, strokeWidth: 1, fade: true, alwaysOn: false, neverOn: false, groupBy: false, wrapClass: true, shadow: false, shadowX: 0, shadowY: 0, shadowRadius: 6, shadowColor: '000000', shadowOpacity: 0.8, shadowPosition: 'outside', shadowFrom: false }); $('img.highlight3').maphilight({ fill: true, fillColor: 'ffffff', fillOpacity: 0.4, stroke: false, strokeColor: '000000', strokeOpacity: 0.5, strokeWidth: 1, fade: true, alwaysOn: false, neverOn: false, groupBy: false, wrapClass: true, shadow: false, shadowX: 0, shadowY: 0, shadowRadius: 6, shadowColor: '000000', shadowOpacity: 0.8, shadowPosition: 'outside', shadowFrom: false });

// Project Overview $('#prOv > div.buttonbox').hover(function(){ $('#prOvText').html($(this).find('.hiddentext').html()) $('#prOvText').show(); },function(){ $('#prOvText').hide(); });

});


$ = jq18;