/*! * 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/ValueStateSupport', 'sap/ui/core/library', 'sap/ui/Device'], function(ValueStateSupport, coreLibrary, Device) { "use strict"; // shortcut for sap.ui.core.ValueState var ValueState = coreLibrary.ValueState; /** * RadioButton renderer. * @namespace */ var RadioButtonRenderer = {}; /** * Renders the HTML for the given control, using the provided {@link sap.ui.core.RenderManager}. * * @param {sap.ui.core.RenderManager} oRm the RenderManager that can be used for writing to the Render-Output-Buffer * @param {sap.ui.core.Control} oRadioButton an object representation of the control that should be rendered */ RadioButtonRenderer.render = function(oRm, oRadioButton) { // get control properties var sId = oRadioButton.getId(); var bEnabled = oRadioButton.getEnabled(); var bEditable = oRadioButton.getEditable(); var bReadOnly = !bEnabled || !bEditable; var bInErrorState = ValueState.Error === oRadioButton.getValueState(); var bInWarningState = ValueState.Warning === oRadioButton.getValueState(); var bInInformationState = ValueState.Information === oRadioButton.getValueState(); var bUseEntireWidth = oRadioButton.getUseEntireWidth(); // Radio Button style class oRm.addClass("sapMRb"); // write the HTML into the render manager oRm.write(""); // DIV element oRm.write("
"); oRm.write(""); // DIV element oRm.write(""); // DIV element // Write the real - potentially hidden - HTML RadioButton element oRm.write(""); // Close RadioButton-input-element oRm.write("
"); // Control - DIVs close oRm.write(""); oRm.renderControl(oRadioButton._oLabel); if (sTooltipWithStateMessage && sap.ui.getCore().getConfiguration().getAccessibility()) { // for ARIA, the tooltip must be in a separate SPAN and assigned via aria-describedby. // otherwise, JAWS does not read it. oRm.write(""); oRm.writeEscaped(sTooltipWithStateMessage); oRm.write(""); } oRm.write(""); // Control - DIVs close }; /** * Returns the correct value of the tooltip. * * @param {sap.m.RadioButton} oRadioButton RadioButton instance. * @returns {string} The correct tooltip value. */ RadioButtonRenderer.getTooltipText = function (oRadioButton) { var sValueStateText = oRadioButton.getProperty("valueStateText"), sTooltipText = oRadioButton.getTooltip_AsString(); if (sValueStateText) { return (sTooltipText ? sTooltipText + " - " : "") + sValueStateText; } else { return ValueStateSupport.enrichTooltip(oRadioButton, sTooltipText); } }; return RadioButtonRenderer; }, /* bExport= */ true);