Hi,

Is there an way (omega enhancement or module) to have a responsive primary menu as seen on www.smashingmagazine.com (top menu links are changed into a dropdown list on narrow screen)

Laurent
Agence Web Coheractio

Comments

marcoka’s picture

you could restyle the menu in one of your responsive css. i think they use js here because what they do would require changing the html markup. with some responsive js trick. you could take a look at the site code.

Agence Web CoherActio’s picture

Will try these.
Many thanks
Laurent

cellar door’s picture

Also another way (non js) is to load your second menu and hide it on certain widths and show on others. I tend to do this by replacing my larger superfish menus with an easy and shortened menu list and just use css to show/hide as needed. The extra menu doesn't use much bandwidth at all

scottsawyer’s picture

Just a quick, totally non-js way to do it.

If you look at the markup, there is a Main Menu in a hidden h2. So, in my global.css, I make it display block, make the ul li display:block,

The whole thing is wrapped in a div or something, so css looks kinda like this

div h2 { display:block; }
div ul ( display: none; }
div:hover ul { display:block; }
div ul li { display:block; }

Now you have a tap friendly drop down that looks like it is triggered by the h2.

You just have to go back and over ride everything in default.css to get your horizontal menu back.

I actually got here because of my own problem. I am using Nice Menu for a drop down on the desktop version of the site, however, I can't find a great way to disable it on the mobile version. It seems to over ride all my style rules.

I really wish Omega just supported second level menu items on the primary menu instead of requiring a module...

Still, the guys did a terrific job :)

IcanDivideBy0’s picture

Thanks,
I used the code from http://mattkersley.com/demos/responsive_menu/ and it works very well. Just be sure to remove the two "console.log" in the jQuery plugin, otherwise, it won't works widows phones.

tnanek’s picture

Just thought I should update you all on the work I'm doing in my sandbox. It is working to implement this technique (as linked above) for Drupal. It is not done yet... see the todo list on the project page for my agenda. I may make it into a full project once those items are taken care of.

The css to add to accomplish the desired affect is going to be similar to what Scott posted above, though a little cleaner in my opinion...

In global.css:

#block-menu-block-<id> ul.menu {
  display:none;
}
#block-menu-block-<id> form {
  display:block;
}

Where ever you want the to toggle that, put that in an @media style sheet. I would advise YOURTHEME-alpha-default-normal.css unless you've changed the settings extensively from the defaults. Include something like the below there.

#block-menu-block-<id> ul.menu {
  display:block;
}
#block-menu-block-<id> form {
  display:none;
}

Disclaimer: I've not tested this yet, so I don't know if display:block is the appropriate setting to use.

Currently, when an item is selected, it will display a button to push to initiate the redirect, and it only displays items from the first level of the menu.

And lastly the link to the sandbox: menu select

DriesP’s picture

Make sure to check out: http://bradfrostweb.com/blog/web/responsive-nav-patterns/

He gives a nice overview of the most common ways to add a responsive menu.

Greetz!

Citlalli’s picture

hello, when i should put the js on drupal?? on libraries to work with the menu responsive??

hydra’s picture

#9 what exactly do you want to achive? To add custom js to youre theme, you can use a preprocess function:

function mytheme_preprocess_page(&$variables) {
    drupal_add_js(path_to_theme() . '/js/custom_script.js');
}
Swebmas’s picture

Any idea why the jquery.mobilemenu.js technic isn't working on a page that load a video from Youtube with the mediafront module? Just to make sure I also tested with the premium Responsive theme /project/responsive because it's using the same technic and it's still not working.

sco_tt’s picture

I've written a little tutorial on how to implement a responsive toggle menu in Omega here:
http://scottpinkelman.com/blog/responsive-toggle-menu-omega

Anonymous’s picture

I've found a perfect tutorial for a responsive menu, here's the link:

But I have one problem, how i can make my menu in the narrow-screen like the mobile menu with the expand button?

A short example:

//This condition will act under the 'mobile' size, and will not be executed on ie6 and ie7
          if (d.to == 'mobile' && !$('html').hasClass('ie6') && !$('html').hasClass('ie7')) {       
           
             //Remove the ´hover´ event in the dropdown menu scrip below              
             $(menuid+' li').unbind();
             $(menuid2+' li').unbind();
              
             //Add a span tag that will aft as the expand button, you can change the output of that button here
             $(menuid+" ul.menu li.expanded").prepend( $("<span class='over' href='#'>Aufklappen &darr;</span>") );     
             $(menuid2+" ul.menu li.expanded").prepend( $("<span class='over' href='#'>Aufklappen &darr;</span>") );     
                      
             //Create an open/close action on the accordion after clicking on the expand element         
             $(menuid+' ul.menu span.over').click(function (event) {     
                 event.preventDefault();
                 if ($(this).siblings('ul').is( ":visible" )){
                 $(this).siblings('ul').slideUp('fast');  
                 } else {           
                 $(this).siblings('ul').slideDown('fast');  
             }                       
             });    
                      
             $(menuid2+' ul.menu span.over').click(function (event) {     
                 event.preventDefault();
                 if ($(this).siblings('ul').is( ":visible" )){
                 $(this).siblings('ul').slideUp('fast');  
                 } else {           
                 $(this).siblings('ul').slideDown('fast');  
             }                       
             });             
          } 

This is a part from the menu.js from the link above. For a test I change the first part of the js above to...

 if (d.to == 'narrow' && !$('html').hasClass('ie6') && !$('html').hasClass('ie7')) { 

...it doesn't work... Of course i have add the same CSS like the global.css in my default-narrow.css. Can anybody help me with this? I want the expand button in the omega mobile- AND narrow-screen. Thanks for help.

Anonymous’s picture

Sorry the link doesn't work, heres again: Creating a responsive menu for omega subthemes

ddille’s picture

You can use the Superfish module to accomplish this.

tanmayk’s picture

There is a module for this. Check out Responsive Menus

Kendall Totten’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

RTBC