WordPress.org

Ready to get started?Download WordPress

Forums

[closed] How does Twenty Twelve Nav Menu Work? (8 posts)

  1. pha3z
    Member
    Posted 1 year ago #

    Can anyone shed some light on how the Twenty Twelve Nav menu works? I'm looking at the tiny js file that contains a function with a few others. There must be some code somewhere else I'm not seeing. I'm baffled.

    The only file I see referenced in the markup is this one:
    twentytwelve/js/navigation.js?ver=1.0

  2. pha3z
    Member
    Posted 1 year ago #

    I thought I wasn't going to figure it out, but I did. So here's the answer in case anyone else wonders.

    navigation.js does all the heavy lifting. The main thing it does is add the class "toggled-on" to the item #site-navigation's child UL element when you click the menu button. When you click the button again, the "toggled-on" class is removed from the ul element. The "toggled-on" class has specific styling in the style.css sheet to control display inline-block and none for the UL. This is how its hidden and revealed everytime you click the button.

  3. ppproperty
    Member
    Posted 1 year ago #

    Ok thats great, but can you shed any light on how to turn off this function in ie 8/7 because at the moment I cannot use this theme even though it is perfect for me in every other way.
    I tried the patch but all it does is spread the nav bar but not the menu out to the proper width.

  4. WTecUK.net
    Member
    Posted 1 year ago #

    I found by reducing the min-width to something tiny or 0, stopped it detecting it.

    Any thoughts on this?

    ------------------------------

    /* Minimum width of 600 pixels. */
    @media screen and (min-width: 100px) {
    .author-avatar {
    float: left;
    margin-top: 8px;
    margin-top: 0.571428571rem;
    }

  5. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    @WTecUk
    If you're looking for support, consider creating your own thread.

  6. WTecUK.net
    Member
    Posted 1 year ago #

    Hi, I'm not after support, I was offering a possible solution.

    Thanks.

  7. 007webby
    Member
    Posted 1 year ago #


    [Moderator note added re the below: any changes to theme files should only be made in a child theme - modifying theme files, especially in the default WP theme is not recommended. You will lose all the changes when WP is updated and it's crucial that you have an unmodified copy on your site for troubleshooting purposes. ]

    Disable Mobile Menu in Twenty Twelve

    I have played around with the new theme today and when I checked my template on the iPad I was presented with the Menu button which I didnt like.

    So here's my workaround:

    • I opened header.php
    • I removed everything between <nav id="site-navigation" class="main-navigation" role="navigation"> and </nav>
    • I created a new div - <div id="topnav"></div>
    • I set up a new sidebar ID in functions.php
    • I pulled in this sidebar into the header.php like this:
      <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Top Navigation') ) : ?>
      <?php endif; ?>
    • I created a menu and pulled the menu in the new sidebar function
    • I can now style my topnav div in CSS as usual, it looks just normal on the iPad now.

    Hope that helps ;-)

  8. SN0WKRASH
    Member
    Posted 1 year ago #

    WTecUK.net that worked for me - I hate that there's no way to do this in the stylesheet for the child theme but if it's the only thing I have to remember to do every time I update then so be it. I hate the responsive menu buttons that much and so do my clients.

    Really bad form for WP to force something like that upon us without any way of disabling or removing it without modifying a core theme file.

    I would like to try 007webby's answer, as it looks like a long-term solution, but the client's site had launched and needed a quick fix.

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.