/*! * 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. */ sap.ui.define([ "sap/ui/core/Renderer", "sap/ui/core/library", "sap/ui/Device", "./library", "./ListItemBaseRenderer", "./Label", "sap/base/Log", "sap/base/security/encodeXML" ], function(Renderer, coreLibrary, Device, library, ListItemBaseRenderer, Label, Log, encodeXML) { "use strict"; // shortcut for sap.m.PopinDisplay var PopinDisplay = library.PopinDisplay; // shortcut for sap.ui.core.VerticalAlign var VerticalAlign = coreLibrary.VerticalAlign; // shortcut for sap.m.PopinLayout var PopinLayout = library.PopinLayout; /** * ColumnListItem renderer. * @namespace */ var ColumnListItemRenderer = Renderer.extend(ListItemBaseRenderer); ColumnListItemRenderer.render = function(rm, oLI) { var oTable = oLI.getTable(); if (!oTable) { return; } ListItemBaseRenderer.render.apply(this, arguments); if (oLI.getVisible() && oTable.hasPopin()) { this.renderPopin(rm, oLI, oTable); } }; // render type highlight always within a cell ColumnListItemRenderer.renderHighlight = function(rm, oLI) { rm.write(''); // let the list item base render the highlight ListItemBaseRenderer.renderHighlight.apply(this, arguments); rm.write(''); }; // render type content always within a cell ColumnListItemRenderer.renderType = function(rm, oLI) { rm.write(''); // let the list item base render the type ListItemBaseRenderer.renderType.apply(this, arguments); rm.write(''); }; // wrap mode content with a cell ColumnListItemRenderer.renderModeContent = function(rm, oLI) { rm.write(''); // let the list item base render the mode control ListItemBaseRenderer.renderModeContent.apply(this, arguments); rm.write(''); }; // ColumnListItem does not respect counter property of the LIB ColumnListItemRenderer.renderCounter = function(rm, oLI) { }; // Returns aria accessibility role ColumnListItemRenderer.getAriaRole = function(oLI) { return ""; }; /** * Renders the HTML for the given control, 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.core.Control} * oControl an object representation of the control that should be * rendered */ ColumnListItemRenderer.renderLIAttributes = function(rm, oLI) { rm.addClass("sapMListTblRow"); var vAlign = oLI.getVAlign(); if (vAlign != VerticalAlign.Inherit) { rm.addClass("sapMListTblRow" + vAlign); } var oTable = oLI.getTable(); if (oTable && oTable.getAlternateRowColors()) { var iPos = oTable.indexOfItem(oLI); if (iPos % 2 == 0) { rm.addClass("sapMListTblRowAlternate"); } } }; /** * Overwriting hook method of ListItemBase * * @public * * @param {sap.ui.core.RenderManager} rm RenderManager * @param {sap.m.ListItemBase} oLI List item */ ColumnListItemRenderer.renderLIContentWrapper = function(rm, oLI) { var oTable = oLI.getTable(); if (!oTable) { return; } var aColumns = oTable.getColumns(true), aCells = oLI.getCells(); // remove cloned headers oLI._destroyClonedHeaders(); aColumns.forEach(function(oColumn, i) { var cls, oHeader, bRenderCell = true, oCell = aCells[oColumn.getInitialOrder()]; if (!oCell || !oColumn.getVisible() || oColumn.isPopin()) { // update the visible index of the column oColumn.setIndex(-1); return; } rm.write(""); if (bRenderCell) { this.applyAriaLabelledBy(oHeader, oCell); rm.renderControl(oCell); } rm.write(""); }, this); }; ColumnListItemRenderer.applyAriaLabelledBy = function(oHeader, oCell) { if (oCell && oCell.removeAriaLabelledBy) { oCell.removeAriaLabelledBy(oCell.data("ariaLabelledBy") || undefined); } /* add the header as an aria-labelled by association for the cells */ /* only set the header text to the aria-labelled association if the header is a textual control and is visible */ if (oHeader && oHeader.getText && oCell.addAriaLabelledBy && oHeader.getVisible()) { oCell.addAriaLabelledBy(oHeader); oCell.data("ariaLabelledBy", oHeader.getId()); } }; /** * Renders pop-ins for Table Rows * * @private * * @param {sap.ui.core.RenderManager} rm RenderManager * @param {sap.m.ListItemBase} oLI List item * @param {sap.m.Table} oTable Table control */ ColumnListItemRenderer.renderPopin = function(rm, oLI, oTable) { // remove existing popin first oLI.removePopin(); // popin row rm.write(""); this.renderHighlight(rm, oLI); // cell rm.write(""); var aCells = oLI.getCells(), aColumns = oTable.getColumns(true); aColumns.forEach(function(oColumn) { if (!oColumn.getVisible() || !oColumn.isPopin()) { return; } var oCell = aCells[oColumn.getInitialOrder()], oHeader = oColumn.getHeader(); if (!oHeader && !oCell) { return; } var sStyleClass = oColumn.getStyleClass(), sPopinDisplay = oColumn.getPopinDisplay(); /* row start */ rm.write(""); /* header cell */ if (oHeader && sPopinDisplay != PopinDisplay.WithoutHeader) { rm.write(""); var fnColumnHeaderClass = sap.ui.require("sap/m/ColumnHeader"); if (typeof fnColumnHeaderClass == "function" && oHeader instanceof fnColumnHeaderClass) { var sColumnHeaderTitle = oHeader.getText(); oHeader = new Label({text: sColumnHeaderTitle}); } else { oHeader = oHeader.clone(); } oColumn.addDependent(oHeader); oLI._addClonedHeader(oHeader); rm.renderControl(oHeader); rm.write(""); /* separator cell */ rm.write("
:
"); } /* value cell */ if (oCell) { rm.write(""); this.applyAriaLabelledBy(oHeader, oCell); rm.renderControl(oCell); rm.write(""); } /* row end */ rm.write(""); }, this); rm.write(""); }; /** * Overwriting hook method of ListItemBase. * * @param {sap.ui.core.RenderManager} rm RenderManager * @param {sap.m.ListItemBase} [oLI] List item */ ColumnListItemRenderer.addLegacyOutlineClass = function(rm, oLI) { }; return ColumnListItemRenderer; }, /* bExport= */ true);