/*!
* 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.f.Avatar
sap.ui.define(["sap/f/library", "sap/base/security/encodeXML"],
function (library, encodeXML) {
"use strict";
// shortcut for sap.f.AvatarSize
var AvatarSize = library.AvatarSize;
// shortcut for sap.f.AvatarType
var AvatarType = library.AvatarType;
/**
* Avatar
renderer.
* @author SAP SE
* @namespace
*/
var AvatarRenderer = {};
/**
* 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} oAvatar an object representation of the control that should be rendered
*/
AvatarRenderer.render = function (oRm, oAvatar) {
var sInitials = oAvatar.getInitials(),
sActualDisplayType = oAvatar._getActualDisplayType(),
sDisplaySize = oAvatar.getDisplaySize(),
sDisplayShape = oAvatar.getDisplayShape(),
sImageFitType = oAvatar.getImageFitType(),
sCustomDisplaySize = oAvatar.getCustomDisplaySize(),
sCustomFontSize = oAvatar.getCustomFontSize(),
sSrc = oAvatar._getEscapedSrc(),
sAvatarClass = "sapFAvatar",
sTooltip = oAvatar.getTooltip_AsString(),
sDefaultTooltip = oAvatar._getDefaultTooltip(),
aLabelledBy = oAvatar.getAriaLabelledBy(),
aDescribedBy = oAvatar.getAriaDescribedBy();
oRm.write(" 0) {
oRm.writeAttributeEscaped("aria-labelledby", aLabelledBy.join(" "));
}
// aria-describedby references
if (aDescribedBy && aDescribedBy.length > 0) {
oRm.writeAttributeEscaped("aria-describedby", aDescribedBy.join(" "));
}
oRm.writeClasses();
oRm.writeStyles();
oRm.write(">");
if (sActualDisplayType === AvatarType.Icon) {
oRm.renderControl(oAvatar._getIcon());
} else if (sActualDisplayType === AvatarType.Initials){
oRm.write("");
oRm.writeEscaped(sInitials);
oRm.write("");
}
// HTML element for the LightBox magnifying glass icon
if (oAvatar._fnLightBoxOpen) {
oRm.write("");
}
oRm.write("");
};
return AvatarRenderer;
}, /* bExport= */ true);