Template:Paris2009 menu5

From 2009.igem.org

(Difference between revisions)
Line 1: Line 1:
-
<html>
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<head>
-
<script type="text/javascript">
+
    <title>Menu accordéon avec jQuery</title>
-
<!--
+
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
/* This script and many more are available free online at
+
<style type="text/css">
-
The JavaScript Source :: http://javascript.internet.com
+
#navigation {
-
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com */
+
margin: 0;
 +
padding: 0;
 +
list-style: none;
 +
background: #000;
 +
color: #fff;
 +
width: 200px;
 +
font: 1.2em "Trebuchet MS", sans-serif;
 +
}
 +
#navigation a, #navigation span {
 +
display: block;
 +
padding: 4px 10px;
 +
color: #fff;
 +
text-decoration: none;
 +
background: #000 url(menu-item.png) left bottom no-repeat;
 +
}
 +
#navigation .toggleSubMenu a, #navigation .toggleSubMenu span {
 +
background-image: url(menu-item-deroule.png);
 +
}
 +
#navigation .open a, #navigation .open span {
 +
background-image: url(menu-item-enroule.png);
 +
}
 +
#navigation a:hover, #navigation a:focus, #navigation a:active {
 +
text-decoration: underline;
 +
}
 +
#navigation .subMenu {
 +
font-size: .8em;
 +
background: #ccc url(subMenu.png) 0 0 repeat-x;
 +
font-size: .9em;
 +
margin: 0;
 +
padding: 0;
 +
border-bottom: 1px solid #666;
 +
}
 +
#navigation ul.subMenu a {
 +
background: none;
 +
padding: 3px 20px;
 +
}
 +
</style>
 +
<!--[if lte IE 6]>
 +
<style type="text/css">
 +
li {
 +
height: 1px;
 +
}
 +
</style>
 +
<![endif]-->
 +
    <script type="text/javascript" src="http://www.alsacreations.com/xmedia/tuto/exemples/accordeon/jquery-1.2.1.js"></script>
 +
    <script type="text/javascript">
 +
    <!--
 +
    $(document).ready( function () {
 +
        // On cache les sous-menus
 +
        // sauf celui qui porte la classe "open_at_load" :
 +
        $("ul.subMenu:not('.open_at_load')").hide();
 +
        // On selectionne tous les items de liste portant la classe "toggleSubMenu"
 +
   
 +
        // et on remplace l'element span qu'ils contiennent par un lien :
 +
        $("li.toggleSubMenu span").each( function () {
 +
            // On stocke le contenu du span :
 +
            var TexteSpan = $(this).text();
 +
            $(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '</a>') ;
 +
        } ) ;
 +
   
 +
        // On modifie l'evenement "click" sur les liens dans les items de liste
 +
        // qui portent la classe "toggleSubMenu" :
 +
        $("li.toggleSubMenu > a").click( function () {
 +
            // Si le sous-menu etait deja ouvert, on le referme :
 +
            if ($(this).next("ul.subMenu:visible").length != 0) {
 +
                $(this).next("ul.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
 +
            }
 +
            // Si le sous-menu est cache, on ferme les autres et on l'affiche :
 +
            else {
 +
                $("ul.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
 +
                $(this).next("ul.subMenu").slideDown("normal", function () { $(this).parent().addClass("open") } );
 +
            }
 +
            // On empêche le navigateur de suivre le lien :
 +
            return false;
 +
        });
 +
   
 +
    } ) ;
 +
    // -->
 +
    </script>
-
/* Coded by Travis Beckham
+
</head>
-
  http://www.squidfingers.com | http://www.podlob.com
+
<body>
-
  version date: 06/02/03
+
    <ul id="navigation">
-
  If want to use this code, feel free to do so, but please leave this message intact. */
+
        <li><a href="" title="">Item 1</a></li>
 +
        <li class="toggleSubMenu"><span>Item 2</span>
 +
            <ul class="subMenu">
 +
                <li><a href="" title="">Item 2.1</a></li>
 +
                <li><a href="" title="">Item 2.2</a></li>
-
// Node Functions
+
                <li><a href="" title="">Item 2.3</a></li>
 +
            </ul>
 +
        </li>
 +
        <li class="toggleSubMenu"><span>Item 3</span>
 +
            <ul class="subMenu">
 +
                <li><a href="" title="">Item 3.1</a></li>
 +
                <li><a href="" title="">Item 3.2</a></li>
-
if(!window.Node){
+
            </ul>
-
  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
+
        </li>
-
}
+
        <li><a href="" title="">Item 4</a></li>
-
 
+
     </ul>  
-
function checkNode(node, filter){
+
-
  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
+
-
}
+
-
 
+
-
function getChildren(node, filter){
+
-
  var result = new Array();
+
-
  var children = node.childNodes;
+
-
  for(var i = 0; i < children.length; i++){
+
-
    if(checkNode(children[i], filter)) result[result.length] = children[i];
+
-
  }
+
-
  return result;
+
-
}
+
-
 
+
-
function getChildrenByElement(node){
+
-
  return getChildren(node, "ELEMENT_NODE");
+
-
}
+
-
 
+
-
function getFirstChild(node, filter){
+
-
  var child;
+
-
  var children = node.childNodes;
+
-
  for(var i = 0; i < children.length; i++){
+
-
    child = children[i];
+
-
    if(checkNode(child, filter)) return child;
+
-
  }
+
-
  return null;
+
-
}
+
-
 
+
-
function getFirstChildByText(node){
+
-
  return getFirstChild(node, "TEXT_NODE");
+
-
}
+
-
 
+
-
function getNextSibling(node, filter){
+
-
  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
+
-
    if(checkNode(sibling, filter)) return sibling;
+
-
  }
+
-
  return null;
+
-
}
+
-
function getNextSiblingByElement(node){
+
-
        return getNextSibling(node, "ELEMENT_NODE");
+
-
}
+
-
 
+
-
// Menu Functions & Properties
+
-
 
+
-
var activeMenu = null;
+
-
 
+
-
function showMenu() {
+
-
  if(activeMenu){
+
-
    activeMenu.className = "";
+
-
    getNextSiblingByElement(activeMenu).style.display = "none";
+
-
  }
+
-
  if(this == activeMenu){
+
-
    activeMenu = null;
+
-
  } else {
+
-
    this.className = "active";
+
-
    getNextSiblingByElement(this).style.display = "block";
+
-
    activeMenu = this;
+
-
  }
+
-
  return false;
+
-
}
+
-
 
+
-
function initMenu(){
+
-
  var menus, menu, text, a, i;
+
-
  menus = getChildrenByElement(document.getElementById("menu"));
+
-
  for(i = 0; i < menus.length; i++){
+
-
    menu = menus[i];
+
-
    text = getFirstChildByText(menu);
+
-
    a = document.createElement("a");
+
-
    menu.replaceChild(a, text);
+
-
    a.appendChild(text);
+
-
    a.href = "#";
+
-
    a.onclick = showMenu;
+
-
    a.onfocus = function(){this.blur()};
+
-
  }
+
-
}
+
-
 
+
-
if(document.createElement) window.onload = initMenu;
+
-
//-->
+
-
</script>
+
-
</head>
+
-
<body>
+
-
<table>
+
-
<ul id="menu">
+
-
  <li class="menu_header">&nbsp;
+
-
<hr>
+
-
  <li class="title">. Home .
+
-
    <ol class="none">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris#top">&nbsp;Synopsis</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Brainstorm#top">&nbsp;Brainstorm</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Project#top">&nbsp;OMV Project</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Conclusion#top">&nbsp;Conclusion</a></li>
+
-
    </ol>
+
-
  </li>
+
-
  <li class="title">. Production .
+
-
    <ol class="none">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Production_overview#top">&nbsp;Overview</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Production_modeling#top">&nbsp;Modeling</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Production_design#top">&nbsp;Parts design</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Production_testing#top">&nbsp;Testing</a></li>
+
-
     </ol>
+
-
  </li>
+
-
  <li class="title">. Addressing .
+
-
    <ol class="none">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Addressing_overview#top">&nbsp;Overview</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Addressing_modeling#top">&nbsp;Modeling</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Addressing_design#top">&nbsp;Parts design</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Addressing_testing#top">&nbsp;Testing</a></li>
+
-
    </ol>
+
-
  </li>
+
-
  <li class="title">. Reception .
+
-
    <ol class="none">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Transduction_overview#top">&nbsp;Overview</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Transduction_modeling#top">&nbsp;Modeling</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Transduction_design#top">&nbsp;Parts design</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Transduction_testing#top">&nbsp;Testing</a></li>
+
-
    </ol>
+
-
  </li>
+
-
  <li class="title">. Ethics .
+
-
    <ol class="block">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Ethics_ethicallabbook#top">&nbsp;Ethical Lab book</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Ethics_ethicalreport#top">&nbsp;Ethical Report</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Ethics_Materials#top">&nbsp;Materials</a></li>
+
-
    </ol>
+
-
  </li>
+
-
  <li class="title">. Tool .
+
-
    <ol class="none">
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Tool_introduction#top">&nbsp;Introduction</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Tool_DataBase#top ">&nbsp;Data Base</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Tool_OSXSoft#top">&nbsp;Software OSX</a></li>
+
-
      <li class="sub"><a href="https://2009.igem.org/Team:Paris/Tool_iPhone#top">&nbsp;iPhone</a></li>
+
-
    </ol>
+
-
<hr>
+
-
  <li class="menu_footer">&nbsp;</li>
+
-
</ul>
+
-
</table>
+
</body>
</body>
-
 
</html>
</html>
-
<div id="paris_content_wrapper">
 
-
<div id=paris_content_boxtop></div>
 
-
<div id="paris_content">
 

Revision as of 15:56, 6 October 2009

Menu accordéon avec jQuery