Team:UCL/Template:headercoll.js

From 2014.igem.org

(Difference between revisions)
(Created page with "(function (window, document) { var layout = document.getElementById('layout'), menu = document.getElementById('menu'), menuLink = document.getElementBy...")
 
Line 1: Line 1:
 +
window.onload = function(){
(function (window, document) {
(function (window, document) {
Line 34: Line 35:
}(this, this.document));
}(this, this.document));
 +
};

Latest revision as of 12:45, 5 August 2014

window.onload = function(){ (function (window, document) {

   var layout   = document.getElementById('layout'),
       menu     = document.getElementById('menu'),
       menuLink = document.getElementById('menuLink');
   function toggleClass(element, className) {
       var classes = element.className.split(/\s+/),
           length = classes.length,
           i = 0;
       for(; i < length; i++) {
         if (classes[i] === className) {
           classes.splice(i, 1);
           break;
         }
       }
       // The className is not found
       if (length === classes.length) {
           classes.push(className);
       }
       element.className = classes.join(' ');
   }
   menuLink.onclick = function (e) {
       var active = 'active';
       e.preventDefault();
       toggleClass(layout, active);
       toggleClass(menu, active);
       toggleClass(menuLink, active);
   };

}(this, this.document)); };