1

I'm trying to figure out how best i can get the following layout in Bootstrap 3 RC2.

Where the left items are the primary nav UL, and the side icons, are an additional UL or just a set of links that share a common look, but provide a dropdown or hide/show toggle for their content (list for the group, but hoping to do an interactive search and cart display for the others).

Currently, this plays fine when i do this code:

<div class="nav-wrapper" style="height: 56px;">
        <div class="nav-primary affix-top">
            <nav class="navbar" role="navigation">
                <div class="container">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">


                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-primary-collapse">
                            <span class="sr-only">Primary navigation</span>
                            <i class="icon-list"></i>
                        </button>

                        <button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".navbar-cart-collapse">
                            <span class="sr-only">Itinerary navigation</span>
                            <span class="icon-calendar-empty"></span>
                        </button>

                        <button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".navbar-user-collapse">
                            <span class="sr-only">User navigation</span>
                            <span class="icon-user"></span>
                        </button>

                        <button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".navbar-search-collapse">
                            <span class="sr-only">Search navigation</span>
                            <span class="icon-search"></span>
                        </button>
                    </div>

                    <div class="row">
                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div class="col-lg-8 col-sm-8 navbar-collapse navbar-primary-collapse in" style="height: auto;">

            <ul id="navPrimary" class="nav navbar-nav">

        <li class="first" id="navRegions"><a href="/regions/">Regions</a></li>

        <li id="navWineries"><a href="/wineries/">Wineries</a></li>

        <li id="navExplore"><a href="/explore/">Explore</a></li>

        <li class="last" id="navEvents"><a href="/events/">Events</a></li>
        </ul> 
                      </div><!-- /.navbar-primary-collapse -->

                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div class="col-lg-4 col-sm-4 pull-right collapse navbar-collapse">
                            <ul class="nav navbar-nav navbar-right">
                                <li>
                                    <a href="#"><i class="icon-search"></i></a>
                                    <div id="prime-nav-searchform" class="dropdown-menu">   <form method="get" action="http://antonibotev.com/themes/nova/" class="search-form">
                                            <i class="icon-search searchform-icon"></i>
                                            <input class="bluebox-search-input" type="text" name="s" value="Search..." onfocus="" onblur="" autocomplete="off" data-view-all-title="Show All Results" data-original-title="">
                                            <input type="submit" class="submit" value="" onfocus="" onblur="">
                                            <div class="search-form-autocomplete active">
                                                <div class="search-results-autocomplete">

                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </li>
                                <li class="dropdown"><a href="#" class="dropdown-toggle"><i class="icon-user"></i>  <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="#">Log In</a></li>
                                        <li><a href="#">Sign Up</a></li>
                                        <li><a href="#">How It Works</a></li>
                                        <li><a href="#">Need Help?</a></li>
                                    </ul>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-calendar-empty"></i> <span>4</span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="#">View Itinerary</a></li>
                                        <li><a href="#">Check Out</a></li>
                                        <li><a href="#">Need Help?</a></li>
                                    </ul>
                                </li>
                            </ul>
                      </div><!-- /.navbar-collapse -->
                    </div>



                </div>
            </nav>
        </div>
    </div>

And this works fine for the initial collapse, but i need additional ones, but currently they need to live in the same UL, which obviously makes an issue with creating the 3 other collapse divs.

I even have the code to toggle the collapses if you say click on search or cart. It will only show you one at a time: opening one and closing the other

// mobile toggles - make sure when one navbar-collapse is open, that the others are closed
$('.navbar-collapse').on('show.bs.collapse', function (e) {
    // hide open menus
    $('.navbar-collapse').each(function(){
        if ($(this).hasClass('in')) {
            $(this).collapse('toggle');
        }
    });
});

The small and xs breakpoints should show the same layout, but of course replace the primary nav with an icon. Idea is that you have 4 icons to simply click or tap to toggle their respective menus, whether those menus contain a list or just a search form.

Any suggestions?

madth3
  • 7,275
  • 12
  • 50
  • 74
  • I like your idea it looks promising! Could your specify what your questions are? What is working and what not. I don't expect you navbar checks will work. First `shown.bs.collapse` will triggered in stead of `show.bs.collapse`. Secondly it is only trigger on a click on the collapsing element. You will need a `$('window').resize()` here. – Bass Jobsen Aug 16 '13 at 10:43
  • Thanks! So here are the primary questions: How do I deal with the icons? Currently, they're using UL's to display, but I don't want them to show the primary links of these within each opening drop down, as a mobile level. So maybe i just use JQuery to hide the anchors, but seems like there should be a better way. I'm not keen on the idea of having buttons and the links in the UL on the right either. Is there a better way to accomplish this? – David Panzarella Aug 16 '13 at 17:46
  • As for the JS, it seems to work fine when toggling the buttons. Shown will only apply after its completely shown, whereas Show will hide the other immediately when another is clicked. As for resizing, it is using the navbar-collapse, so it only happens at the small breakpoint, so no need for resize as far as i can tell. – David Panzarella Aug 16 '13 at 17:46
  • okay, thanks. Maybe you should consider: http://getbootstrap.com/css/#responsive-utilities to build different views (navbars) for mobile and bigger screens. – Bass Jobsen Aug 19 '13 at 17:41

1 Answers1

0

I think this NAVBAR i made is very close to what you're looking for. I've posted this answer before, but it applies to your question very well.

This example shows how to have just about any kind of 'vanilla bootstrap' NAVBAR configuration you could want. It includes a site title, both collapsing and non-collapsing menu items aligned left or right, and static text. The example also has a drop-down menu with an icon.

Be sure to read the comments to get a fuller understanding of what you can change. Enjoy!

Fiddle: http://jsfiddle.net/nomis/n9KtL/1/

<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
  <div class="container">

    <!-- Title -->
    <div class="navbar-header pull-left">
      <a href="/" class="navbar-brand">GNOMIS</a>
    </div>

    <!-- 'Sticky' (non-collapsing) right-side menu item(s) -->
    <div class="navbar-header pull-right">
      <ul class="nav pull-left">
        <!-- This works well for static text, like a username -->
        <li class="navbar-text pull-left">User Name</li>
        <!-- Add any additional bootstrap header items.  This is a drop-down from an icon -->
        <li class="dropdown pull-right">
          <a href="#" data-toggle="dropdown" style="color:#777; margin-top: 5px;" class="dropdown-toggle"><span class="glyphicon glyphicon-user"></span><b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li>
              <a href="/users/id" title="Profile">Profile</a>
            </li>
            <li>
              <a href="/logout" title="Logout">Logout </a>
            </li>
          </ul>
        </li>
      </ul>

      <!-- Required bootstrap placeholder for the collapsed menu -->
      <button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
    </div>

    <!-- The Collapsing items            navbar-left or navbar-right -->
    <div class="collapse navbar-collapse navbar-left">
      <!--                      pull-right keeps the drop-down in line -->
      <ul class="nav navbar-nav pull-right">
        <li><a href="/news">News</a></li>
        <li><a href="/Shop">Shop</a></li>
      </ul>
    </div>

    <!-- Additional navbar items -->
    <div class="collapse navbar-collapse navbar-right">
      <!--                      pull-right keeps the drop-down in line -->
      <ul class="nav navbar-nav pull-right">
        <li><a href="/locator">Locator</a></li>
        <li><a href="/extras">Extras</a></li>
      </ul>
    </div>
  </div>
</nav>
nomis
  • 1,582
  • 14
  • 14