Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <nav id="site-navigation" class="main-navigation toggled" role="navigation">
- <h1 class="menu-toggle">+</h1>
- <div class="menu">
- <ul class=" nav-menu">
- <li><a>Home</a>
- </li>
- <li><a>Contact</a>
- </li>
- <li><a>Sample Page</a>
- </li>
- <li><a>The Emperor’s New Clothes</a>
- </li>
- </ul>
- </div>
- </nav>
- .menu-toggle {
- display: block;
- position: absolute;
- right: 45px;
- top: 20px;
- width: 25px;
- height: 25px;
- z-index: 999;
- font-size: 30px;
- line-height: 1;
- font-weight: 800;
- text-shadow: 2px 2px #fff;
- }
- .menu-open {
- -moz-transform: rotate(45deg);
- -webkit-transform: rotate(45deg);
- -o-transform: rotate(45deg);
- -ms-transform: rotate(45deg);
- transform: rotate(45deg);
- font-size: 30px;
- line-height: 1;
- font-weight: 800;
- text-shadow: 2px 2px SpringGreen;
- }
- .menu-toggle, .main-navigation.toggled .nav-menu {
- display: block;
- }
- /**
- * navigation.js
- *
- * Handles toggling the navigation menu for small screens.
- */
- ( function() {
- var container, button, menu, menuToggle;
- container = document.getElementById( 'site-navigation' );
- if ( ! container )
- return;
- button = container.getElementsByTagName( 'h1' )[0];
- if ( 'undefined' === typeof button )
- return;
- menu = container.getElementsByTagName( 'ul' )[0];
- menuToggle = container.getElementsByClassName( 'menu-toggle' )[0];
- // Hide menu toggle button if menu is empty and return early.
- if ( 'undefined' === typeof menu ) {
- button.style.display = 'none';
- return;
- }
- if ( -1 === menu.className.indexOf( 'nav-menu' ) )
- menu.className += ' nav-menu';
- button.onclick = function() {
- if ( -1 !== container.className.indexOf( 'toggled' ) )
- container.className = container.className.replace( 'toggled', '' );
- else
- container.className += 'toggled';
- }
- } )();
- /* $(this).toggleClass('menu-open'); */
- button.addEventListener("click", function() {
- // Code here
- }, false);
- button.attachEvent("onclick", function() {
- // Code here
- });
- if (button.addEventListener) {
- button.addEventListener("click", handleTheEvent, false);
- }
- else if (button.attachEvent) {
- button.attachEvent("onclick", handleTheEvent);
- }
- function handleTheEvent() {
- // ...code here...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement