/*! * UI development toolkit for HTML5 (OpenUI5) * (c) Copyright 2009-2018 SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ // Provides default renderer for control sap.ui.commons.MenuBar sap.ui.define(['jquery.sap.global'], function(jQuery) { "use strict"; /** * MenuBarRenderer. * @namespace */ var MenuBarRenderer = { }; /** * Renders the HTML for the given menubar using the provided {@link sap.ui.core.RenderManager}. * * @param {sap.ui.core.RenderManager} oRenderManager The RenderManager that can be used for writing to the render output buffer. * @param {sap.ui.commons.Toolbar} oToolbar An object representation of the control that should be rendered. */ MenuBarRenderer.render = function(oRenderManager, oMenuBar) { var rm = oRenderManager; oMenuBar.doBeforeRendering(); rm.write(""); var iVisibleItemIdx = 0; var aItems = oMenuBar.getItems(); for (var i = 0; i < aItems.length; i++) { var oItem = aItems[i]; if (oItem.getVisible()) { iVisibleItemIdx++; rm.write(""); rm.writeEscaped(oItem.getText()); rm.write(""); } } rm.write(""); }; MenuBarRenderer.writeAria = function(rm, sRole, sText, bDisabled, iIdx, bHasSubMenu){ if (sText) { rm.writeAttributeEscaped("title", sText); } if (!sap.ui.getCore().getConfiguration().getAccessibility()) { return; } rm.writeAttribute("role", sRole); if (sRole == "menuitem") { if (bHasSubMenu) { rm.writeAttribute("aria-haspopup", true); } rm.writeAttribute("aria-posinset", iIdx); } if (bDisabled) { rm.writeAttribute("aria-disabled", true); } }; return MenuBarRenderer; }, /* bExport= */ true);