/*! * 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(['jquery.sap.global'], function(jQuery) { "use strict"; /** * InPlaceEdit renderer. * @namespace */ var InPlaceEditRenderer = { }; /** * 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} oInPlaceEdit an object representation of the control that should be rendered */ InPlaceEditRenderer.render = function(rm, oInPlaceEdit){ var oContent = oInPlaceEdit.getContent(); var sWidth; if (oContent) { if (oContent.getWidth) { sWidth = oContent.getWidth(); } if (oContent.getVisible && !oContent.getVisible()) { // invisible -> render nothing jQuery.sap.log.warning("Content is not visivle - nothing is rendered", this); return; } } else { // no content -> render nothing jQuery.sap.log.warning("No content provided - nothing is rendered", this); return; } // write the HTML into the render manager rm.write(""); // DIV if (oInPlaceEdit._sOldTextAvailable || oContent.getMetadata().getName() == "sap.ui.commons.Link") { // there is an old text available - put content in an extra DIV to position // for Link do it always to have the edit button next to the link, but have the defined width for the outer DIV rm.write(""); // DIV } if (oInPlaceEdit._bEditMode) { this.renderEditContent(rm, oInPlaceEdit); } else { this.renderDisplayContent(rm, oInPlaceEdit); } if (oInPlaceEdit._sOldTextAvailable || oContent.getMetadata().getName() == "sap.ui.commons.Link") { rm.write(""); if (oInPlaceEdit.getUndoEnabled() && oInPlaceEdit._sOldTextAvailable) { // there is an old text available and undo enabled - render undo button rm.renderControl(oInPlaceEdit._oUndoButton); } } rm.write(""); }; InPlaceEditRenderer.renderDisplayContent = function(rm, oInPlaceEdit){ if (oInPlaceEdit._oDisplayControl) { rm.renderControl(oInPlaceEdit._oDisplayControl); if (oInPlaceEdit.getEditable() && oInPlaceEdit._oDisplayControl.getMetadata().getName() == "sap.ui.commons.Link") { rm.renderControl(oInPlaceEdit._oEditButton); } } }; InPlaceEditRenderer.renderEditContent = function(rm, oInPlaceEdit){ if (oInPlaceEdit._oEditControl) { rm.renderControl(oInPlaceEdit._oEditControl); } }; return InPlaceEditRenderer; }, /* bExport= */ true);