/*! * 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/Device", "sap/ui/core/InvisibleText"], function(Device, InvisibleText) { "use strict"; /** * SearchField renderer. * @namespace */ var SearchFieldRenderer = { }; /** * Renders the HTML for the given control, using the provided {@link sap.ui.core.RenderManager}. * * @param {sap.ui.core.RenderManager} rm the RenderManager that can be used for writing to the Render-Output-Buffer * @param {sap.ui.core.Control} oSF an object representation of the control that should be rendered */ SearchFieldRenderer.render = function(rm, oSF){ // render nothing if control is invisible if (!oSF.getVisible()) { return; } var sPlaceholder = oSF.getPlaceholder(), sValue = oSF.getValue(), sWidth = oSF.getProperty("width"), sId = oSF.getId(), bShowRefreshButton = oSF.getShowRefreshButton(), bShowSearchBtn = oSF.getShowSearchButton(), oAccAttributes = {}, // additional accessibility attributes sToolTipValue, sRefreshToolTip = oSF.getRefreshButtonTooltip(), sResetToolTipValue, bAccessibility = sap.ui.getCore().getConfiguration().getAccessibility(); // container rm.write(""); // 1. Input type="search". // Enclose input into a
to show a correct keyboard rm.write(''); // self-made placeholder if (!oSF._hasPlaceholder && sPlaceholder) { rm.write(""); } rm.write('= 4 && Device.os.version < 4.1 ) { rm.addClass("sapMSFIA4"); // specific CSS layout for Android 4.0x } rm.writeClasses(); if (oSF.getEnableSuggestions() && Device.system.phone) { // Always open a dialog on a phone if suggestions are on. // To avoid soft keyboard flickering, set the readonly attribute. rm.writeAttribute("readonly", "readonly"); } if (!oSF.getEnabled()) { rm.writeAttribute("disabled","disabled"); } if (sPlaceholder) { rm.writeAttributeEscaped("placeholder", sPlaceholder); } if (oSF.getMaxLength()) { rm.writeAttribute("maxLength", oSF.getMaxLength()); } if (sValue) { rm.writeAttributeEscaped("value", sValue); } //ARIA attributes if (oSF.getEnabled() && bShowRefreshButton) { var sAriaF5LabelId = InvisibleText.getStaticId("sap.m", "SEARCHFIELD_ARIA_F5"); if ( sAriaF5LabelId ) { oAccAttributes.describedby = { value: sAriaF5LabelId, append: true }; } } var sInvisibleTextId = oSF.getId() + "-I" + "-labelledby"; oAccAttributes.labelledby = { value: sInvisibleTextId, append: true }; rm.writeAccessibilityState(oSF, oAccAttributes); rm.write(">"); //Invisible text for ACC purpose - announcing placeholder when there is Label or Tooltip for the Input if (bAccessibility) { var sAnnouncement = oSF.getPlaceholder() || ""; if (sAnnouncement) { rm.write(""); rm.writeEscaped(sAnnouncement.trim()); rm.write(""); } } if (oSF.getEnabled()) { // 2. Reset button rm.write(""); // 3. Search/Refresh button if (bShowSearchBtn) { rm.write(""); } } rm.write(""); rm.write(""); }; return SearchFieldRenderer; }, /* bExport= */ true);