am I correct when I say, that highlighting the current section (or area or specific DIV) in a OnePage project requires some JS? And if so, did you ever accomplished this in conjunction with our standard #fwNav1 (CSS Menu Action)?
Looking like so:
I assume it’s something like add class of “foo” on click - perhaps?
basically only the specific menu item. But the other one sounds tempting, too.
I’m currently developing a “new way (not really new)” of navigating through projects. Bye Bye - sucking BigAreaMenu or even two or three ones - welcome the future kinda stuff, you know. The Project that tells a story - literally. And the story makes the navigation. But there are still some concerns, and the better indication of “where the user is” could be one strong argument.
This is theProject, placed on dropbox so hopefully reachable (never tried):
In my case when the user selects a section to view I use js to smooth scroll to the anchor then use pure CSS (no js-applied styles) to highlight the content using :target and :focus pseudo-elements. Quite easy.
Ahm - I have to admit, that I don’t have much idea, if not to say nil about all those pseudo link selectors in conjunction with the Freeway CSS Menu.
The :target would highlight the sectionDIV(?), but I’d like to start with just the link background in the menuBar - and here I don’t get my head around getting this.
I think I have to have another read somewhere in the depth of W3C and others.
Walther did this a while ago, I’m trying to remember what that one was … it was done via javascript. I’ll read out all of my posts of the last two years, see if I can find it …
This is pretty easily done in JS. You listen for a click on a particular type of element, then remove the “active” class from everywhere it is currently applied and apply it to the element you have just clicked. This will not give you the “scroll-spy” behavior you may have seen, where as you scroll down your single-page “site”, the sticky header lights up to indicate the currently-visible section. That takes a bit more work, because you have to work out what is visible at the moment.
If you can use Prototype (which means you aren’t using jQuery) then you can simply do this to get the former working immediately: (and you have to have your .active class-based style set up to add the highlight)
// listen for clicks on any li inside the #fwNav1 list (includes sub-menu options)
document.on(‘click’, ‘#fwNav1 li’, function(evt, elm){
if(elm.match(‘#fwNav1 > li’)){
// it’s a top-level option
$$(‘.active’).invoke(‘removeClassName’, ‘active’);
elm.addClassName(‘active’);
}else if(evt.findElement(‘#fwNav1 > li’)){
// set the highlight on the parent top-level option
$$(‘.active’).invoke(‘removeClassName’, ‘active’);
evt.findElement(‘#fwNav1 > li’).addClassName(‘active’);
}
});
Now all of this should be possible anyway if you’re using the stock CSS Menus in Freeway 7 — there’s a checkbox in the Action interface to highlight the current link. Does that not work in a single-page site?
Walter
On Sep 1, 2015, at 3:07 AM, Richard van Heukelum email@hidden wrote:
Walther did this a while ago, I’m trying to remember what that one was … it was done via javascript. I’ll read out all of my posts of the last two years, see if I can find it …
Affordable in a onePage project with a handful of links, but if a project grows above the onePage I think the JS solution is the better choice perhaps.
The simple “highlight page” within the action doesn’t work (it does - but only on multiple-page architecture). But I might miss something - that’s always possible.