/*!
* 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/library',
'sap/ui/core/IconPool',
'sap/m/library',
'sap/ui/core/InvisibleText',
"sap/base/security/encodeXML"
],
function(Device, coreLibrary, IconPool, library, InvisibleText, encodeXML) {
"use strict";
// shortcut for sap.m.ButtonType
var ButtonType = library.ButtonType;
// shortcut for sap.ui.core.TextDirection
var TextDirection = coreLibrary.TextDirection;
/**
* Button renderer.
* @namespace
*/
var ButtonRenderer = {};
/**
* 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} oButton
* the button to be rendered
*/
ButtonRenderer.render = function(oRm, oButton) {
// get control properties
var sType = oButton.getType();
var bEnabled = oButton.getEnabled();
var sWidth = oButton.getWidth();
var sTooltip = oButton._getTooltip();
var sText = oButton._getText();
var sTextDir = oButton.getTextDirection();
var bIE_Edge = Device.browser.internet_explorer || Device.browser.edge;
// render bdi tag only if the browser is different from IE and Edge since it is not supported there
var bRenderBDI = (sTextDir === TextDirection.Inherit) && !bIE_Edge;
// get icon from icon pool
var sBackURI = IconPool.getIconURI("nav-back");
// start button tag
oRm.write("");
};
/**
* HTML for image
*
* @param {sap.ui.core.RenderManager} oRm
* the RenderManager that can be used for writing to
* the Render-Output-Buffer
* @param {sap.ui.core.Control} oButton
* the button to be rendered
* @private
*/
ButtonRenderer.writeImgHtml = function(oRm, oButton) {
oRm.renderControl(oButton._getImage((oButton.getId() + "-img"), oButton.getIcon(), oButton.getActiveIcon(), oButton.getIconDensityAware()));
};
/**
* @param {sap.ui.core.RenderManager} oRm
* the RenderManager that can be used for writing to
* the Render-Output-Buffer
* @param {sap.ui.core.Control} oButton
* the button to be rendered
* @param {sap.ui.core.URI} sURI
* URI of the icon to be written
* HTML for internal image (icon pool)
*/
ButtonRenderer.writeInternalIconPoolHtml = function(oRm, oButton, sURI) {
oRm.renderControl(oButton._getInternalIconBtn((oButton.getId() + "-iconBtn"), sURI));
};
/**
* Renders tabindex with value of "-1" if required by _bExcludeFromTabChain property.
* @param {sap.m.Button} oButton The sap.m.Button to be rendered
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the Render-Output-Buffer
*/
function renderTabIndex(oButton, oRm){
if (oButton._bExcludeFromTabChain) {
oRm.writeAttribute("tabindex", -1);
}
}
var mARIATextKeys = {
Accept: "BUTTON_ARIA_TYPE_ACCEPT",
Reject: "BUTTON_ARIA_TYPE_REJECT",
Emphasized: "BUTTON_ARIA_TYPE_EMPHASIZED"
};
ButtonRenderer.getButtonTypeAriaLabelId = function(sType) {
return InvisibleText.getStaticId("sap.m", mARIATextKeys[sType]);
};
return ButtonRenderer;
}, /* bExport= */ true);