Tuesday, June 19, 2012

SubMenu.js


//-----------------------------------------------------
// Display sub menu for the specified module
//-----------------------------------------------------
function showSubMenu(module) {
    if (document.getElementById(module + "SubMenu") != null) {
        document.getElementById(module + "SubMenu").style.top =
                top.frames["navBar"].document.getElementById(module).offsetTop + 22;
        document.getElementById(module + "SubMenu").style.display = "";
    }
    var oWindow = top.frames["apps"];
    setTimeout(function () {
        setupClickHandler(oWindow);
    }, 100);
}

//-----------------------------------------------------
// Setup handlers to hide menu on click in iframes
//-----------------------------------------------------
function setupClickHandler(oWindow) {
    if (oWindow.document.readyState != "complete") {
        setTimeout(function () {
            setupClickHandler(oWindow);
        }, 1000);
        return;
    }
    if (!oWindow.hasClickHandler && oWindow.document.body) {
        oWindow.document.body.attachEvent("onclick", top.hideSubMenu);
        oWindow.hasClickHandler = true;
    }
    var frames = oWindow.document.frames;
    for (var i = 0; frames != null && i < frames.length; i++) {
        setupClickHandler(frames[i]);
    }
}

//-----------------------------------------------------
// Handler for mouse over specified menu item
//-----------------------------------------------------
function menuItemMouseOver(obj) {
    obj.style.background = "#DBE8FC";
}

//-----------------------------------------------------
// Handler for mouse leaving specified menu item
//-----------------------------------------------------
function menuItemMouseOut(obj) {
    obj.style.background = "";
}

//-----------------------------------------------------
// Block default context menu for specified object
//-----------------------------------------------------
function blockContextMenu(obj) {
    var rightclick;
    var e = window.event;
    if (e.which) {
        rightclick = (e.which == 3);
    }
    else if (e.button) {
        rightclick = (e.button == 2);
    }
    if (rightclick) {
        obj.attachEvent ("oncontextmenu", function() {
            return false;
        });
    }
}

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home