Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding a delay to menu collapse

    Hi, On a menu I am using, I need help on adding a delay to my CSS Menu before it collapses. Using IE, you cannot select any submenu items apart from the bottom one. A link is attached.


    Firefox is fine, i can select any of my submenu items.

    Also, I am using csshover.htc file to enable my hovers to work in IE. Is there anything I can add into that to get it to work properly under IE?

    CSSHover.htc file contents:

    <attach event="ondocumentready" handler="parseStylesheets" />

    <script>

    var csshoverReg = /(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+))hover|active)/i,

    currentSheet, doc = window.document, hoverEvents = [], activators = {

    onhover:{on:'onmouseover', off:'onmouseout'},

    onactive:{on:'onmousedown', off:'onmouseup'}

    }



    function parseStylesheets() {

    if(!/MSIE (5|6)/.test(navigator.userAgent)) return;

    window.attachEvent('onunload', unhookHoverEvents);

    var sheets = doc.styleSheets, l = sheets.length;

    for(var i=0; i<l; i++)

    parseStylesheet(sheets[i]);

    }

    function parseStylesheet(sheet) {

    if(sheet.imports) {

    try {

    var imports = sheet.imports, l = imports.length;

    for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);

    } catch(securityException){}

    }



    try {

    var rules = (currentSheet = sheet).rules, l = rules.length;

    for(var j=0; j<l; j++) parseCSSRule(rules[j]);

    } catch(securityException){}

    }



    function parseCSSRule(rule) {

    var select = rule.selectorText, style = rule.style.cssText;

    if(!csshoverReg.test(select) || !style) return;



    var pseudo = select.replace(/[^:]+[a-z-]+).*/i, 'on$1');

    var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);

    var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];

    var affected = select.replace(/hover|active).*$/, '');

    var elements = getElementsBySelect(affected);

    if(elements.length == 0) return;



    currentSheet.addRule(newSelect, style);

    for(var i=0; i<elements.length; i++)

    new HoverElement(elements[i], className, activators[pseudo]);

    }



    function HoverElement(node, className, events) {

    if(!node.hovers) node.hovers = {};

    if(node.hovers[className]) return;

    node.hovers[className] = true;

    hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });

    hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });

    }

    function hookHoverEvent(node, type, handler) {

    node.attachEvent(type, handler);

    hoverEvents[hoverEvents.length] = {

    node:node, type:type, handler:handler

    };

    }



    function unhookHoverEvents() {

    for(var e,i=0; i<hoverEvents.length; i++) {

    e = hoverEvents[i];

    e.node.detachEvent(e.type, e.handler);

    }

    }



    function getElementsBySelect(rule) {

    var parts, nodes = [doc];

    parts = rule.split(' ');

    for(var i=0; i<parts.length; i++) {

    nodes = getSelectedNodes(parts[i], nodes);

    } return nodes;

    }

    function getSelectedNodes(select, elements) {

    var result, node, nodes = [];

    var identify = (/\#([a-z0-9_-]+)/i).exec(select);

    if(identify) {

    var element = doc.getElementById(identify[1]);

    return element? [element]:nodes;

    }



    var classname = (/\.([a-z0-9_-]+)/i).exec(select);

    var tagName = select.replace(/(\.|\#|\[a-z0-9_-]+/i, '');

    var classReg = classname? new RegExp('\\b' + classname[1] + '\\b'):false;

    for(var i=0; i<elements.length; i++) {

    result = tagName? elements[i].all.tags(tagName):elements[i].all;

    for(var j=0; j<result.length; j++) {

    node = result[j];

    if(classReg && !classReg.test(node.className)) continue;

    nodes[nodes.length] = node;

    }

    }



    return nodes;

    }

    </script>

    Any help appreciated, thanks
    Last edited by raks; 08-24-2007 at 02:42 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •