Template:Team:Edinburgh/Code
From 2013.igem.org
(Difference between revisions)
Hristianita (Talk | contribs) |
Hristianita (Talk | contribs) |
||
Line 361: | Line 361: | ||
$(function() { | $(function() { | ||
- | + | var touchscreen = ("ontouchstart" in document.documentElement); | |
- | + | var active=1; | |
- | + | var menu_buttons = $(".menu_button"); | |
- | + | for (var i=0; i< menu_buttons.length; i++) { | |
- | + | active=1; | |
- | + | var menu_links = $(menu_buttons[i]).children("a"); | |
- | + | for (var j=0; j < menu_links.length; j++) { | |
- | + | if (menu_links[j].href.indexOf("Team:Edinburgh/") > -1) { | |
- | + | if (window.location.href.indexOf(menu_links[j].href) > -1) { | |
- | + | ||
active = 3; | active = 3; | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
} | } | ||
+ | } else if (window.location.href.indexOf(menu_links[j].href, window.location.href.length - menu_links[j].href.length) >-1) { | ||
+ | active = 3; | ||
} | } | ||
- | + | } | |
- | + | $(menu_links).css("display", "none"); | |
- | + | menu_links[active-1].style.display = "block"; | |
- | + | ||
- | + | if (touchscreen) continue; | |
- | + | ||
- | + | menu_buttons[i].onmouseover = (function() { | |
- | + | var children = $(menu_buttons[i]).children("a"); | |
- | + | return function() { | |
- | + | $(children).css("display", "none"); | |
- | + | children[1].style.display = "block"; | |
- | + | } | |
- | + | })(); | |
- | + | ||
- | + | menu_buttons[i].onmouseout = (function() { | |
- | + | var children = $(menu_buttons[i]).children("a"); | |
- | + | return function() { | |
+ | active=1; | ||
+ | for (var j=0; j < children.length; j++) { | ||
+ | if (children[j].href.indexOf("Team:Edinburgh/") > -1) { | ||
+ | if (window.location.href.indexOf(children[j].href) > -1) { | ||
+ | active = 3; | ||
+ | } | ||
+ | } else if (window.location.href.indexOf(children[j].href, window.location.href.length - children[j].href.length) >-1) { | ||
+ | active = 3; | ||
+ | } | ||
+ | } | ||
+ | $(children).css("display", "none"); | ||
+ | children[active-1].style.display = "block"; | ||
+ | } | ||
+ | })(); | ||
} | } | ||
}); | }); |
Revision as of 00:13, 4 October 2013