Team:ETH Zurich/collapsible

From 2013.igem.org

(Difference between revisions)
(Created page with "<html> <script type="text/javascript"> /** * Dynamic Navigation Bars. See Wikipedia:NavFrame * * Based on script from en.wikipedia.org, 2008-09-15. * * @source www.medi...")
Line 1: Line 1:
-
<html>
+
<html lang="en">
-
<script type="text/javascript">
+
<head>
-
/**
+
  <meta charset="utf-8" />
-
* Dynamic Navigation Bars. See [[Wikipedia:NavFrame]]
+
  <title>jQuery UI Accordion - Default functionality</title>
-
*
+
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
-
* Based on script from en.wikipedia.org, 2008-09-15.
+
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
-
*
+
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
-
* @source www.mediawiki.org/wiki/MediaWiki:Gadget-NavFrame.js
+
  <link rel="stylesheet" href="/resources/demos/style.css" />
-
* @maintainer Helder.wiki, 2012–2013
+
  <script>
-
* @maintainer Krinkle, 2013
+
  $(function() {
-
*/
+
    $( "#accordion" ).accordion();
-
( function () {
+
  });
 +
  </script>
 +
</head>
 +
<body>
   
   
-
// Set up the words in your language
+
<div id="accordion">
-
var collapseCaption = 'hide';
+
  <h3>Section 1</h3>
-
var expandCaption = 'show';
+
  <div>
 +
    <p>
 +
    Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
 +
    ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
 +
    amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
 +
    odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
 +
    </p>
 +
  </div>
 +
  <h3>Section 2</h3>
 +
  <div>
 +
    <p>
 +
    Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
 +
    purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
 +
    velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
 +
    suscipit faucibus urna.
 +
    </p>
 +
  </div>
 +
  <h3>Section 3</h3>
 +
  <div>
 +
    <p>
 +
    Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
 +
    Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
 +
    ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
 +
    lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
 +
    </p>
 +
    <ul>
 +
      <li>List item one</li>
 +
      <li>List item two</li>
 +
      <li>List item three</li>
 +
    </ul>
 +
  </div>
 +
  <h3>Section 4</h3>
 +
  <div>
 +
    <p>
 +
    Cras dictum. Pellentesque habitant morbi tristique senectus et netus
 +
    et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
 +
    faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
 +
    mauris vel est.
 +
    </p>
 +
    <p>
 +
    Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
 +
    Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
 +
    inceptos himenaeos.
 +
    </p>
 +
  </div>
 +
</div>
   
   
-
var navigationBarHide = '[' + collapseCaption + ']';
 
-
var navigationBarShow = '[' + expandCaption + ']';
 
   
   
-
/**
+
</body>
-
* Shows and hides content and picture (if available) of navigation bars.
+
-
*
+
-
* @param {number} indexNavigationBar The index of navigation bar to be toggled
+
-
* @param {jQuery.Event} e Event object
+
-
*/
+
-
function toggleNavigationBar( indexNavigationBar, e ) {
+
-
        var navChild,
+
-
                navToggle = document.getElementById( 'NavToggle' + indexNavigationBar ),
+
-
                navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
+
-
+
-
        // Prevent browser from jumping to href "#"
+
-
        e.preventDefault();
+
-
+
-
        if ( !navFrame || !navToggle ) {
+
-
                return false;
+
-
        }
+
-
+
-
        // If shown now
+
-
        if ( navToggle.firstChild.data == navigationBarHide ) {
+
-
                for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
+
-
                        if ( hasClass( navChild, 'NavPic' ) ) {
+
-
                                navChild.style.display = 'none';
+
-
                        }
+
-
                        if ( hasClass( navChild, 'NavContent' ) ) {
+
-
                                navChild.style.display = 'none';
+
-
                        }
+
-
                }
+
-
                navToggle.firstChild.data = navigationBarShow;
+
-
+
-
        // If hidden now
+
-
        } else if ( navToggle.firstChild.data == navigationBarShow ) {
+
-
                for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
+
-
                        if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
+
-
                                navChild.style.display = 'block';
+
-
                        }
+
-
                }
+
-
                navToggle.firstChild.data = navigationBarHide;
+
-
        }
+
-
}
+
-
+
-
/**
+
-
* Adds show/hide-button to navigation bars.
+
-
*
+
-
* @param {jQuery} $content
+
-
*/
+
-
function createNavigationBarToggleButton( $content ) {
+
-
        var i, j, navFrame, navToggle, navToggleText, navChild,
+
-
                indexNavigationBar = 0,
+
-
                navFrames = $content.find( 'div.NavFrame' ).toArray();
+
-
+
-
        // Iterate over all (new) nav frames
+
-
        for ( i = 0; i < navFrames.length; i++ ) {
+
-
                navFrame = navFrames[i];
+
-
                // If found a navigation bar
+
-
                indexNavigationBar++;
+
-
                navToggle = document.createElement( 'a' );
+
-
                navToggle.className = 'NavToggle';
+
-
                navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
+
-
                navToggle.setAttribute( 'href', '#' );
+
-
                $( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );
+
-
+
-
                navToggleText = document.createTextNode( navigationBarHide );
+
-
                for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
+
-
                        if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
+
-
                                if ( navChild.style.display == 'none' ) {
+
-
                                        navToggleText = document.createTextNode( navigationBarShow );
+
-
                                        break;
+
-
                                }
+
-
                        }
+
-
                }
+
-
+
-
                navToggle.appendChild( navToggleText );
+
-
                // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
+
-
                for ( j = 0; j < navFrame.childNodes.length; j++ ) {
+
-
                        if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
+
-
                                navFrame.childNodes[j].appendChild( navToggle );
+
-
                        }
+
-
                }
+
-
                navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
+
-
        }
+
-
}
+
-
+
-
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
+
-
+
-
}());
+
-
</script>
+
-
<style type="text/css">
+
-
/* Standard Navigationsleisten, aka box hiding thingy
+
-
  from .de.  Documentation at [[Wikipedia:NavFrame]]. */
+
-
div.NavFrame {
+
-
    margin: 0;
+
-
    padding: 4px;
+
-
    border: 1px solid #aaa;
+
-
    text-align: center;
+
-
    border-collapse: collapse;
+
-
    font-size: 95%;
+
-
}
+
-
div.NavFrame + div.NavFrame {
+
-
    border-top-style: none;
+
-
    border-top-style: hidden;
+
-
}
+
-
div.NavPic {
+
-
    background-color: #fff;
+
-
    margin: 0;
+
-
    padding: 2px;
+
-
    /* @noflip */
+
-
    float: left;
+
-
}
+
-
div.NavFrame div.NavHead {
+
-
    height: 1.6em;
+
-
    font-weight: bold;
+
-
    background-color: #ccf;
+
-
    position: relative;
+
-
}
+
-
div.NavFrame p,
+
-
div.NavFrame div.NavContent,
+
-
div.NavFrame div.NavContent p {
+
-
    font-size: 100%;
+
-
}
+
-
div.NavEnd {
+
-
    margin: 0;
+
-
    padding: 0;
+
-
    line-height: 1px;
+
-
    clear: both;
+
-
}
+
-
a.NavToggle {
+
-
    position: absolute;
+
-
    top: 0;
+
-
    /* @noflip */
+
-
    right: 3px;
+
-
    font-weight: normal;
+
-
    font-size: 90%;
+
-
}
+
-
</style>
+
</html>
</html>

Revision as of 14:31, 23 October 2013

jQuery UI Accordion - Default functionality

Section 1

Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.

Section 2

Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.

Section 3

Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.

  • List item one
  • List item two
  • List item three

Section 4

Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est.

Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.