Ticket #358: wordcamp-base.patch
File wordcamp-base.patch, 4.3 KB (added by , 11 years ago) |
---|
-
header.php
22 22 if ( is_singular() && get_option( 'thread_comments' ) ) 23 23 wp_enqueue_script( 'comment-reply' ); 24 24 25 // Adds JavaScript for handling the navigation menu hide-and-show behavior to allow responsive menus. 26 wp_enqueue_script( 'wordcamp-base-navigation', get_template_directory_uri() . '/lib/navigation/navigation.js', array(), '1.0', true ); 27 28 25 29 /* Always have wp_head() just before the closing </head> 26 30 * tag of your theme, or you will break many plugins, which 27 31 * generally use this hook to add elements to <head> such -
lib/navigation/navigation.js
1 /** 2 * navigation.js 3 * 4 * Handles toggling the navigation menu for small screens. 5 */ 6 ( function() { 7 var nav = document.getElementById( 'access' ), button, menu; 8 if ( ! nav ) 9 return; 10 button = nav.getElementsByTagName( 'h3' )[0]; 11 menu = nav.getElementsByTagName( 'ul' )[0]; 12 if ( ! button ) 13 return; 14 15 // Hide button if menu is missing or empty. 16 if ( ! menu || ! menu.childNodes.length ) { 17 button.style.display = 'none'; 18 return; 19 } 20 21 button.onclick = function() { 22 if ( -1 == menu.className.indexOf( 'menu' ) ) 23 menu.className = 'menu'; 24 25 if ( -1 != button.className.indexOf( 'toggled-on' ) ) { 26 button.className = button.className.replace( ' toggled-on', '' ); 27 menu.className = menu.className.replace( ' toggled-on', '' ); 28 } else { 29 button.className += ' toggled-on'; 30 menu.className += ' toggled-on'; 31 } 32 }; 33 } )(); 34 No newline at end of file -
lib/navigation/navigation.js
1 /** 2 * navigation.js 3 * 4 * Handles toggling the navigation menu for small screens. 5 */ 6 ( function() { 7 var nav = document.getElementById( 'access' ), button, menu; 8 if ( ! nav ) 9 return; 10 button = nav.getElementsByTagName( 'h3' )[0]; 11 menu = nav.getElementsByTagName( 'ul' )[0]; 12 if ( ! button ) 13 return; 14 15 // Hide button if menu is missing or empty. 16 if ( ! menu || ! menu.childNodes.length ) { 17 button.style.display = 'none'; 18 return; 19 } 20 21 button.onclick = function() { 22 if ( -1 == menu.className.indexOf( 'menu' ) ) 23 menu.className = 'menu'; 24 25 if ( -1 != button.className.indexOf( 'toggled-on' ) ) { 26 button.className = button.className.replace( ' toggled-on', '' ); 27 menu.className = menu.className.replace( ' toggled-on', '' ); 28 } else { 29 button.className += ' toggled-on'; 30 menu.className += ' toggled-on'; 31 } 32 }; 33 } )(); 34 No newline at end of file -
lib/structure/class-wcb-menu.php
8 8 function content() { ?> 9 9 <div id="<?php echo $this->get_id(); ?>" class="grid_12"> 10 10 <div id="access" role="navigation" class="clearfix"> 11 <?php /* Menu toggle element for responsive menus - hidden by default CSS */ ?> 12 <h3 class="menu-toggle"><?php _e( 'Menu', 'wordcampbase' ); ?></h3> 11 13 <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?> 12 14 <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'wordcampbase' ); ?>"><?php _e( 'Skip to content', 'wordcampbase' ); ?></a></div> 13 15 <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?> -
style.css
375 375 margin: 0 auto; 376 376 width: 940px; 377 377 } 378 /* Hide the responsive menu toggle - maintain backwards compatibility */ 379 #access .menu-toggle { 380 display: none; 381 } 378 382 #access .menu-header, 379 383 div.menu { 380 384 font-size: 13px;