Ticket #21697: 21697.diff

File 21697.diff, 2.0 KB (added by lancewillett, 9 months ago)

Refreshed patch with a bit of commenting

Line 
1Index: wp-content/themes/twentytwelve/style.css
2===================================================================
3--- wp-content/themes/twentytwelve/style.css    (revision 21651)
4+++ wp-content/themes/twentytwelve/style.css    (working copy)
5@@ -540,6 +540,15 @@
6        display: inline-block;
7 }
8 
9+/* Show navigation when JavaScript is off */
10+.no-js .main-navigation ul.nav-menu,
11+.no-js .main-navigation div.nav-menu > ul {
12+       display: block;
13+}
14+.no-js .menu-toggle {
15+       display: none;
16+}
17+
18 /* Banner */
19 section[role="banner"] {
20        margin-bottom: 48px;
21Index: wp-content/themes/twentytwelve/functions.php
22===================================================================
23--- wp-content/themes/twentytwelve/functions.php        (revision 21651)
24+++ wp-content/themes/twentytwelve/functions.php        (working copy)
25@@ -376,6 +376,14 @@
26        elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
27                $classes[] = 'custom-background-white';
28 
29+       /*
30+        * Provides support for JavaScript-disabled visitors,
31+        * allowing the menu to always show in small windows.
32+        *
33+        * Value is changed in navigation.js.
34+        */
35+       $classes[] = 'no-js';
36+
37        return $classes;
38 }
39 add_filter( 'body_class', 'twentytwelve_body_class' );
40Index: wp-content/themes/twentytwelve/js/navigation.js
41===================================================================
42--- wp-content/themes/twentytwelve/js/navigation.js     (revision 21651)
43+++ wp-content/themes/twentytwelve/js/navigation.js     (working copy)
44@@ -4,10 +4,13 @@
45  * Handles toggling the navigation menu for small screens.
46  */
47 ( function() {
48+       // Remove no-js class from body.
49+       document.body.className = document.body.className.replace( 'no-js', 'js' );
50+
51        var button = document.getElementById( 'site-navigation' ).getElementsByTagName( 'h3' )[0],
52            menu   = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];
53 
54-       if ( undefined == button || undefined == menu )
55+       if ( undefined === button || undefined === menu )
56                return false;
57 
58        button.onclick = function() {