Modification on CSSMenu.js

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

Modification on CSSMenu.js

Post by jack4ya »

Q:
The default installation also shows the problem:
Section headers now... open the site in IE6... When you hover over the section header, things start to shift up!

A:
The problem lies in the javascript. And I think the solution should be included in the core also!

CODE

var cssid = "primary-nav"; // CSS ID for the menuwrapper
var menuadd = "h";  // Character to be added to the specific classes upon hovering. So for example, if this is set to "h", class "menuparent" will become "menuparenth" when hovered over.
var menuh = "menuh"; // Classname for hovering over all other menu items

if (window.attachEvent) window.attachEvent("onload", cssHover);

function cssHover() {
  var sfEls = document.getElementById(cssid).getElementsByTagName("LI");
  for (var i=0; i<sfEls.length; i++) {

    if(sfEls.className.indexOf("sectionheader") == -1){

      sfEls.onmouseover=function() {
        if (this.className != "") {
            this.className = this.className + menuadd;
        }
        else { 
            this.className = menuh;
        }
      }

      sfEls.onmouseout=function() {
        if (this.className == menuh) {
            this.className = "";
        }
        else {
            this.className = this.className.replace(new RegExp(menuadd + "$"), "");
        }
      }
    }
  }
}
reidjazz

Re: Modification on CSSMenu.js

Post by reidjazz »

What really needs to happen is to abandon the javascript ALTOGETHER. Impossible you say? If you think you need JS for drop down menus (especially to accomodate IE), then check out http://www.cssplay.co.uk/menus/basic_dd.html. No javascript here. I'd love to convert this to a Smarty template, but I'm no coder.

Any takers out there? I'm sure there are those that know smarty well enough to convert this.

reidjazz
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

Re: Modification on CSSMenu.js

Post by jack4ya »

I agree, I 'normally' use those css menu in non cmsmadesimple site, simply because I have difficulties (re)writing something with menu manager. Also I love the downstates, those need to be inserted as well.

I'll have another look when I have time (not this week anyway)
Post Reply

Return to “Tips and Tricks”