Template:WUR script.js

From 2012.igem.org

(Difference between revisions)
Line 1: Line 1:
-
/*
+
var jQueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
-
* Kleuren:
+
//var cssUrl = "http://www.the-falcons.nl/igem2/style.css";
-
* - Zwart: 000000
+
var cssUrl = "https://2012.igem.org/Template:WUR_style.css?action=raw&ctype=text/css";
-
* - Blauw/grijs: 005172, cbd5d8, e3e9ea
+
var nivoJsUrl = 'https://2012.igem.org/Template:WUR_nivo.js?action=raw&ctype=text/javascript';
-
* - Groen: 0d623c, 118450, 16ad69
+
var nivoCssUrl = "https://2012.igem.org/Template:WUR_nivo.css?action=raw&ctype=text/css";
-
*  - Rood: b92c33
+
var prefixfreeUrl = 'https://2012.igem.org/Template:WUR_prefixfree.js?action=raw&ctype=text/javascript';
-
*/
+
-
/* General */
+
var headerImgUrl = "";
-
body { background: white; font-family: Tahoma, Geneva, sans-serif; }
+
-
.hidden { display: none; }
+
-
.cols { clear: both; width: 965px; }
+
var jQueryScriptOutputted = false;
-
.col { width: 305px; padding: 0 25px 0 0; float: left; }
+
-
.col:last-child { padding: 0; }
+
-
.left { float: left; }
+
function initJQuery() {
-
.right { float: right; }
+
 +
    //if the jQuery object isn't available
 +
    if (typeof(jQuery) == 'undefined') {
-
h2 { border-bottom: 2px solid #005172; }
+
        if (! jQueryScriptOutputted) {
-
h2.ulc1 { border-color: #0d623c; }
+
            //only output the script once..
-
h2.ulc2 { border-color: #b92c33; }
+
            jQueryScriptOutputted = true;
 +
           
 +
            //output the script (load it from google api)
 +
            document.write("<script type=\"text/javascript\" src=\"" + jQueryUrl + "\"></script>");
-
/* Slider */
+
        }
-
#header_slider {
+
        setTimeout("initJQuery()", 50);
-
position: relative;
+
    } else {
-
height: 200px;
+
        $(function() {
-
overflow: hidden;
+
jQuery(document).ready(function(){
-
background: url(https://static.igem.org/mediawiki/2012/b/bd/Slider1.jpg) left top no-repeat;
+
-
}
+
// CSS
-
#header_slider > div.logo {
+
$("<link/>", {
-
position: absolute;
+
rel: "stylesheet",
-
top: 10px;
+
type: "text/css",
-
left: 10px;
+
href: cssUrl
-
z-index: 999;
+
}).appendTo("head");
-
}
+
-
#header_slider > div.logo a, #header_slider > div.logo img {
+
/*
-
height: 150px; width: 250px;
+
// Slider
-
border: 0;
+
$("<link/>", {
-
}
+
rel: "stylesheet",
-
 
+
type: "text/css",
-
/* Navigatie / menu */
+
href: nivoCssUrl
-
#navContainer { height: 25px; }
+
}).appendTo("head");
-
#navContainer ul { list-style: none; padding: 0; margin: 0; float: left; }
+
$.getScript(nivoJsUrl, function(){
-
#navContainer ul li { float: left; position: relative; z-index: 5; }
+
//http://nivo.dev7studios.com/support/jquery-plugin-usage/
-
#navContainer ul li a, #navContainer ul li strong {
+
$('#header_slider').nivoSlider({
-
display: block;
+
effect: 'fade',
-
padding: 0 20px 0 5px;
+
directionNav: false,
-
text-decoration: none;
+
controlNav: false,
-
border-bottom: 2px solid white;
+
pauseTime: 5500,
-
height: 25px;
+
animSpeed: 1000
-
line-height: 25px;
+
});
-
}
+
});
-
 
+
*/
-
#navContainer ul li a:hover, #navContainer ul li strong { text-decoration: none; border-bottom: 2px solid #0d623c; cursor: pointer; }
+
-
#navContainer ul li.ulc1 a:hover, #navContainer ul li.ulc1 strong { border-color: #005172; }
+
// Move menu
-
#navContainer ul li.ulc2 a:hover, #navContainer ul li.ulc2 strong { border-color: #b92c33; }
+
var menu = $('#navContainer');
-
 
+
$('#navContainer').remove();
-
#navContainer ul li ul li a:hover, #navContainer ul li.ulc1 ul li a:hover, #navContainer ul li.ulc2 ul li a:hover { border-bottom: 2px solid #0d623c; }
+
$('#content').prepend(menu);
-
#navContainer ul li ul li.ulc1 a:hover, #navContainer ul li ul li.ulc1 strong { border-color: #005172; }
+
-
#navContainer ul li ul li.ulc2 a:hover, #navContainer ul li ul li.ulc2 strong { border-color: #b92c33; }
+
// Move header
-
 
+
var header = $('#header_wrapper');
-
#navContainer ul li > ul {
+
$('#header_wrapper').remove();
-
visibility: hidden;
+
$('#content').prepend(header);
-
position: absolute;
+
-
left: 0px;
+
// Decorate menu
-
top: 26px;
+
function decorateMenu(el, i) {
-
background: white;
+
switch(i) {
-
box-shadow: 1px 1px 4px #666;
+
case 1: el.addClass('ulc1'); i += 1;
-
z-index: 1;
+
break;
-
height: auto;
+
-
min-width: 200px;
+
case 2: el.addClass('ulc2'); i += 1;
-
opacity: 0;
+
break;
-
transition: opacity .25s linear;
+
-
}
+
case 3: i = 1;
-
#navContainer ul li:hover { z-index: 50; }
+
break;
-
#navContainer ul li:hover > ul {
+
-
visibility: visible;
+
default: i += 1;
-
z-index: 99;
+
}
-
opacity: 1;
+
return i;
-
}
+
}
-
#navContainer ul li ul li { z-index: 199; float: none; }
+
var i = 0;
-
 
+
var ii = 0;
-
#navContainer > ul > li > ul > li > ul {
+
menu.find('li').each(function(){
-
position: absolute;
+
i = decorateMenu($(this),i);
-
top: 0px;
+
ii = $(this).find('ul').find('li').each(function(){decorateMenu($(this),ii);});
-
left: 200px;
+
});
-
z-index: 900;
+
-
}
+
// 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
-
#socialmediaicons {
+
// website.
-
float: right;
+
menu.find('[title]').removeAttr('title');
-
margin-left: 10px;
+
-
}
+
// Google Analytics
-
 
+
var ga_script = "\
-
/* Body */
+
<script type=\"text/javascript\">\
-
#bodyContent {
+
  var _gaq = _gaq || [];\
-
width: 965px;
+
  _gaq.push(['_setAccount', 'UA-33423824-1']);\
-
padding: 0 0 20px 0;
+
  _gaq.push(['_trackPageview']);\
-
}
+
  (function() {\
-
 
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\
-
a.bigbutton, a.bigbutton:visited {
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\
-
display: block;
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\
-
overflow: hidden;
+
  })();\
-
color: #111;
+
</script>";
-
text-decoration: none;
+
$('head').append(ga_script);
-
padding: 10px 10px 10px 80px;
+
-
border-radius: 4px;
+
// Move the Footer
-
min-height: 50px;
+
$('#contentfooter').appendTo('#content');
-
background-color: #fff;
+
-
background-repeat: no-repeat;
+
$('.bigbutton').hover(function(){
-
background-position: 10px center;
+
$(this).find('img').animate({
-
box-shadow: none;
+
'margin-top': '-175px'
-
transition: all .25s linear;
+
},'fast');
-
}
+
},function(){
-
a.bigbutton:hover {
+
$(this).find('img').animate({
-
box-shadow: 1px 1px 3px #666;
+
'margin-top': '0px'
-
text-decoration: none;
+
},'fast');
-
background-color: #ccc;
+
});
-
}
+
-
a.bConstructor { background-image: url(/wiki/images/6/61/Constructor.png); }
+
/*
-
a.bTeam        { background-image: url(/wiki/images/b/b8/WURTeam.png); }
+
// Effect on the home buttons
-
a.bPublication { background-image: url(/wiki/images/d/d0/Publication.png); }
+
$('.homebutton').hover(function(){
-
a.bUrl        { background-image: url(/wiki/images/0/05/Url.png); }
+
$(this).animate({
-
a.bSource      { background-image: url(/wiki/images/b/b0/Source.png); }
+
  height: "300",
-
a.bPoster      { background-image: url(/wiki/images/f/fc/Poster.png); }
+
  width: "480",
-
 
+
  left: "-=90",
-
/* Footer */
+
  top: "-=50",
-
#contentfooter {
+
  'border-radius': '5px'
-
width: 965px;
+
}, "fast");
-
clear: both;
+
},function(){
-
margin: 10px 0;
+
$(this).animate({
-
padding: 20px 0;
+
height: "200",
-
border-top: 2px solid #b92c33;
+
width: "320",
-
overflow: hidden;
+
left: "+=90",
-
}
+
  top: "+=50",
-
#contentfooter .fcol {
+
  'border-radius': '0px'
-
float: left;
+
}, "fast");
-
width: 320px;
+
});
-
padding-right: 1px;
+
*/
-
}
+
-
 
+
// If an anchor-link was pressed, make sure the scrolling was done correctly.
-
/* Home Intro */
+
if(location.hash) {
-
#projectIntro {
+
var sId = location.hash.substr(1);
-
height: 340px;
+
var sEl = document.getElementById(sId);
-
margin-bottom: 20px;
+
var sJQ = $(sEl);
-
position: relative;
+
-
text-align: center;
+
setTimeout(function(){
-
}
+
$(document).scrollTop(sJQ.offset().top);
-
#projectVideo {
+
}, 250);
-
  width: 480px;
+
-
  background: #ddd url('http://png-5.findicons.com/files/icons/1676/primo/128/button_grey_play.png') no-repeat center center;
+
}
-
  height: 320px;
+
-
  margin: 10px auto;
+
// Fix prefixes for CSS3 styles
-
}
+
$.getScript(prefixfreeUrl, function(){});
-
#toProjectOverview {
+
-
  position: absolute;
+
// Animate the project overview
-
  right: 20px;
+
$('#poPnas, #poVLPs, #poOutside, #poInside, #poApplications').hide();
-
  bottom: 10px;
+
$('#poPnas').fadeIn(500, function(){
-
}
+
$('#poVLPs').fadeIn(500, function(){
-
#toProjectOverview a {
+
$('#poOutside').fadeIn(500, function(){
-
  display: block;
+
$('#poInside').fadeIn(500, function(){
-
  padding: 8px;
+
$('#poApplications').fadeIn(500, function(){});
-
  border-radius: 5px;
+
});
-
  background-color: #999;
+
});
-
  color: #111;
+
});
-
  transition: background-color .25s;
+
});
-
}
+
-
#toProjectOverview a:hover {
+
// Click actions for the project overview
-
  background-color: #ddd;
+
function poLoad(url) {
-
  text-decoration: none;
+
$('#poTextClose').fadeOut();
-
  color: #333;
+
$('#poText').slideUp().fadeOut('fast', function(){
-
}
+
$('#poLoading').fadeIn('fast');
-
 
+
$('#poText').load(url, function(){
-
/* Project Overview Graphic */
+
$('#poLoading').fadeOut('fast');
-
#projectOverview {
+
$('#poTextClose').fadeIn();
-
height: 340px;
+
$(this).fadeIn().slideDown();
-
margin-bottom: 20px;
+
});
-
background: url(/wiki/images/4/4c/Vlp.png) center top no-repeat;
+
});
-
position: relative;
+
}
-
}
+
$('#poTextClose').click(function() {
-
 
+
$('#poText').slideUp().fadeOut();
-
#projectOverview > div.buttonbox {
+
$('#poTextClose').fadeOut();
-
position: absolute;
+
});
-
width: 205px;
+
$('#poPnas').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/Pnas_ProjectOverview?action=render'); });
-
height: 90px;
+
$('#poVLPs').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/VLPs_ProjectOverview?action=render'); });
-
padding: 8px;
+
$('#poOutside').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/OutsideModification_ProjectOverview?action=render'); });
-
background-color: white;
+
$('#poInside').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/InsideModification_ProjectOverview?action=render'); });
-
border: 1px solid #ccc;
+
$('#poApplications').click(function(){ poLoad('https://2012.igem.org/Team:Wageningen_UR/Applications_ProjectOverview?action=render'); });
-
border-radius: 3px;
+
-
text-align: center;
+
-
font-size: 18pt;
+
});
-
font-weight: bold;
+
});
-
color: #555;
+
}
-
}
+
-
#projectOverview > div.buttonbox:hover { background: #ccc; cursor: pointer; box-shadow: 1px 1px 3px #999; }
+
-
 
+
-
#poPnas { top: 50px; left: 0px; }
+
-
#poVLPs { top: 180px; left: 0px; }
+
-
#poOutside { top: 10px; right: 0px; }
+
-
#poInside { top: 120px; right: 0px; }
+
-
#poApplications { top: 230px; right: 0px; }
+
-
 
+
-
#projectOverview > div p {
+
-
margin: 8px 0; padding: 0;
+
-
}
+
-
 
+
-
#poLoading {
+
-
position: absolute;
+
-
display: none;
+
-
z-index: 999;
+
-
font-size: 16pt;
+
-
color: white;
+
-
font-weight: bold;
+
-
text-align: center;
+
-
left: 0; right: 0; top: 0; bottom: 0;
+
-
padding: 100px;
+
-
background: #111;
+
-
background: rgba(0,0,0,0.4);
+
-
}
+
-
#poText {
+
-
position: absolute;
+
-
display: none;
+
-
top: 20px; bottom: 20px;
+
-
left: 240px; right: 240px;
+
-
padding: 20px;
+
-
background: white;
+
-
background: rgba(255,255,255,0.9);
+
-
border: 1px solid #111;
+
-
overflow: auto;
+
-
z-index: 998;
+
-
border-radius: 3px;
+
-
}
+
-
#poTextClose {
+
-
position: absolute;
+
-
display: none;
+
-
top: 21px;
+
-
right: 256px;
+
-
width: 20px;
+
-
height: 20px;
+
-
background: #eee;
+
-
color: #111;
+
-
font-weight: bold;
+
-
text-align: center;
+
-
font-size: 18px;
+
-
line-height: 20px;
+
-
z-index: 999;
+
-
cursor: pointer;
+
-
border-radius: 3px;
+
}
}
-
/* 'Hacks' */
+
if(location.action!="render") {
-
#content { border: 0; padding: 0; }
+
initJQuery();
-
.firstHeading,
+
-
#search-controls,
+
-
#catlinks,
+
-
#toc,
+
-
#p-logo { display: none; }
+
-
#top-section { height: 18px; border: 0; }
+
-
#menubar {
+
-
background: transparent;
+
-
padding: 0;
+
-
top: 0;
+
}
}
-
.left-menu:hover { background: transparent; }
 
-
.left-menu a, .left-menu:hover a { color: black; }
 
-
.right-menu li a { background: transparent; color: black; }
 
-
#footer-box { margin-top: 50px; }
 

Revision as of 10:14, 19 September 2012

var jQueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'; //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 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 = "";

var jQueryScriptOutputted = false;

function initJQuery() {

   //if the jQuery object isn't available
   if (typeof(jQuery) == 'undefined') {
       if (! jQueryScriptOutputted) {
           //only output the script once..
           jQueryScriptOutputted = true;
           
           //output the script (load it from google api)
           document.write("<script type=\"text/javascript\" src=\"" + jQueryUrl + "\"></script>");
       }
       setTimeout("initJQuery()", 50);
   } else {
       $(function() {

jQuery(document).ready(function(){

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

/* // Slider $("<link/>", { rel: "stylesheet", type: "text/css", href: nivoCssUrl }).appendTo("head"); $.getScript(nivoJsUrl, function(){ //http://nivo.dev7studios.com/support/jquery-plugin-usage/ $('#header_slider').nivoSlider({ effect: 'fade', directionNav: false, controlNav: false, pauseTime: 5500, animSpeed: 1000 }); }); */

// 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'); });


}); }); } }

if(location.action!="render") { initJQuery(); }