Created
October 15, 2010 16:29
-
-
Save meeech/628497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A plugin class designed to extend Y.Plugin.NodeMenuNav to allow pining of menu | |
// We want to allow a submenu to specify bltl, tlbr and so forth | |
function NavPinSubMenu() { | |
NavPinSubMenu.superclass.constructor.apply(this, arguments); | |
} | |
// Define Static properties NAME (to identify the class) and NS (to identify the namespace) | |
NavPinSubMenu.NAME = 'navPinSunMenu'; | |
NavPinSubMenu.NS = 'menuNav'; | |
// Attribute definitions for the plugin | |
NavPinSubMenu.ATTRS = { | |
}; | |
//Main class uses this, but its not in an accessible way that I can see? | |
//suggestions please. | |
var getParentMenu = function (node) { | |
return node.ancestor(MENU_SELECTOR); | |
}; | |
// Extend Plugin.Base | |
Y.extend(NavPinSubMenu, Y.Plugin.NodeMenuNav, { | |
/** | |
* @method _showMenu | |
* @description Shows the specified menu. | |
* @protected | |
* @param {Node} menu Node instance representing a menu. | |
*/ | |
_showMenu: function (menu) { | |
var oParentMenu = getParentMenu(menu), | |
oLI = menu.get(PARENT_NODE), | |
aXY = oLI.getXY(); | |
if (this.get(USE_ARIA)) { | |
menu.set(ARIA_HIDDEN, false); | |
} | |
if (isHorizontalMenu(oParentMenu)) { | |
aXY[1] = aXY[1] + oLI.get(OFFSET_HEIGHT); | |
} | |
else { | |
aXY[0] = aXY[0] + oLI.get(OFFSET_WIDTH); | |
} | |
menu.setXY(aXY); | |
if (UA.ie < 8) { | |
if (UA.ie === 6 && !menu.hasIFrameShim) { | |
menu.appendChild(Y.Node.create(NodeMenuNav.SHIM_TEMPLATE)); | |
menu.hasIFrameShim = true; | |
} | |
// Clear previous values for height and width | |
menu.setStyles({ height: EMPTY_STRING, width: EMPTY_STRING }); | |
// Set the width and height of the menu's bounding box - this is | |
// necessary for IE 6 so that the CSS for the <iframe> shim can | |
// simply set the <iframe>'s width and height to 100% to ensure | |
// that dimensions of an <iframe> shim are always sync'd to the | |
// that of its parent menu. Specifying a width and height also | |
// helps when positioning decorator elements (for creating effects | |
// like rounded corners) inside a menu's bounding box in IE 7. | |
menu.setStyles({ | |
height: (menu.get(OFFSET_HEIGHT) + PX), | |
width: (menu.get(OFFSET_WIDTH) + PX) }); | |
} | |
menu.previous().addClass(CSS_MENU_LABEL_MENUVISIBLE); | |
menu.removeClass(CSS_MENU_HIDDEN); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment