Make WordPress Core

Changeset 21929


Ignore:
Timestamp:
09/20/2012 04:28:27 PM (13 years ago)
Author:
lancewillett
Message:

Twenty Twelve: update navigation script to check for missing button and menu children earlier; allows an empty menu to be set without showing the button. See #21678.

Location:
trunk/wp-content/themes/twentytwelve
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r21886 r21929  
    9999     * Adds JavaScript for handling the navigation menu hide-and-show behavior.
    100100     */
    101     wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120824', true );
     101    wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120920', true );
    102102
    103103    /*
  • trunk/wp-content/themes/twentytwelve/js/navigation.js

    r21616 r21929  
    88        menu   = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];
    99
    10     if ( undefined == button || undefined == menu )
     10    if ( undefined === button )
    1111        return false;
     12
     13    // Hide button if menu is missing or empty.
     14    if ( undefined === menu || ! menu.childNodes.length ) {
     15        button.style.display = 'none';
     16        return false;
     17    }
    1218
    1319    button.onclick = function() {
     
    2329        }
    2430    };
    25 
    26     // Hide menu toggle button if menu is empty.
    27     if ( ! menu.childNodes.length )
    28         button.style.display = 'none';
    2931} )();
Note: See TracChangeset for help on using the changeset viewer.