DVHMA/DVHMA-OpenUI5/www/resources/sap/m/ComboBoxBaseRenderer-dbg.js

140 lines
5.0 KiB
JavaScript

/*!
* SAP UI development toolkit for HTML5 (SAPUI5/OpenUI5)
* (c) Copyright 2009-2015 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
*/
sap.ui.define(['jquery.sap.global', './InputBaseRenderer', 'sap/ui/core/Renderer'],
function(jQuery, InputBaseRenderer, Renderer) {
"use strict";
/**
* ComboBoxBase renderer.
*
* @namespace
*/
var ComboBoxBaseRenderer = Renderer.extend(InputBaseRenderer);
/**
* CSS class to be applied to the root element of the ComboBoxBase.
*
* @readonly
* @const {string}
*/
ComboBoxBaseRenderer.CSS_CLASS = "sapMComboBoxBase";
/**
* Writes attributes to the control's root element.
* To be overwritten by subclasses.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.writeOuterAttributes = function(oRm, oControl) {
// note: in IE browsers, JAWS 15.0 announce the ComboBox only if
// the role combobox is set to the control's root element
oRm.writeAttribute("role", "combobox");
};
/**
* Add attributes to the input element.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.writeInnerAttributes = function(oRm, oControl) {
oRm.writeAttribute("autocomplete", "off");
oRm.writeAttribute("autocorrect", "off");
oRm.writeAttribute("autocapitalize", "off");
};
/**
* Writes the accessibility state.
* To be overwritten by subclasses.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.writeAccessibilityState = function(oRm, oControl) {
InputBaseRenderer.writeAccessibilityState.apply(this, arguments);
oRm.writeAccessibilityState(oControl, {
role: "combobox",
expanded: oControl.isOpen(),
autocomplete: "both"
});
};
/**
* Add extra styles for input container.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.addOuterStyles = function(oRm, oControl) {
oRm.addStyle("max-width", oControl.getMaxWidth());
};
/**
* Add classes to the ComboBox.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.addOuterClasses = function(oRm, oControl) {
var CSS_CLASS = ComboBoxBaseRenderer.CSS_CLASS;
oRm.addClass(CSS_CLASS);
oRm.addClass(CSS_CLASS + "Input");
if (!oControl.getEnabled()) {
oRm.addClass(CSS_CLASS + "Disabled");
}
if (!oControl.getEditable()) {
oRm.addClass(CSS_CLASS + "Readonly");
}
};
/**
* Add inner classes to the ComboBox's input element.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.addInnerClasses = function(oRm, oControl) {
var CSS_CLASS = ComboBoxBaseRenderer.CSS_CLASS;
oRm.addClass(CSS_CLASS + "InputInner");
if (!oControl.getEditable()) {
oRm.addClass(CSS_CLASS + "InputInnerReadonly");
}
};
/**
* Renders the ComboBox's arrow, 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} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.writeInnerContent = function(oRm, oControl) {
oRm.write('<button tabindex="-1"');
oRm.writeAttribute("id", oControl.getId() + "-arrow");
this.addButtonClasses(oRm, oControl);
oRm.writeClasses();
oRm.write("></button>");
};
/**
* Add CSS classes to the combo box arrow button, using the provided {@link sap.ui.core.RenderManager}.
* To be overwritten by subclasses.
*
* @param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the render output buffer.
* @param {sap.ui.core.Control} oControl An object representation of the control that should be rendered.
*/
ComboBoxBaseRenderer.addButtonClasses = function(oRm, oControl) {
oRm.addClass(ComboBoxBaseRenderer.CSS_CLASS + "Arrow");
};
return ComboBoxBaseRenderer;
}, /* bExport= */ true);