UNPKG

@openui5/sap.ui.core

Version:

OpenUI5 Core Library sap.ui.core

1,286 lines (1,179 loc) 79.7 kB
/*! * OpenUI5 * (c) Copyright 2026 SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ /** * @fileoverview * @deprecated As of version 1.120.0 */ sap.ui.define([ // new sap/base/* modules "sap/base/util/now", "sap/base/util/Version", "sap/base/assert", "sap/base/Log", // new sap/ui/* modules "sap/ui/dom/includeScript", "sap/ui/dom/includeStylesheet", "sap/ui/security/FrameOptions", "sap/ui/performance/Measurement", "sap/ui/performance/trace/Interaction", "sap/base/util/LoaderExtensions", // former sap-ui-core.js dependencies "sap/ui/Device", "sap/ui/thirdparty/jquery", "ui5loader-autoconfig", "jquery.sap.stubs" ], function(now, Version, assert, Log, includeScript, includeStylesheet, FrameOptions, Measurement, Interaction, LoaderExtensions, Device, jQuery /* , ui5loaderAutoconfig, jquerySapStubs */) { "use strict"; if ( !jQuery ) { throw new Error("Loading of jQuery failed"); } var ui5loader = sap.ui.loader; if ( !ui5loader || !ui5loader._ ) { throw new Error("The UI5 compatilbility module requires a UI5 specific AMD implementation"); } var _ui5loader = ui5loader._; (function() { /** * Holds information about the browser's capabilities and quirks. * This object is provided and documented by jQuery. * But it is extended by SAPUI5 with detection for features not covered by jQuery. This documentation ONLY covers the detection properties added by UI5. * For the standard detection properties, please refer to the jQuery documentation. * * These properties added by UI5 are only available temporarily until jQuery adds feature detection on their own. * * @name jQuery.support * @namespace * @private * @deprecated since 1.58 use {@link sap.ui.Device} instead */ jQuery.support = jQuery.support || {}; /** * Whether the device has a retina display (window.devicePixelRatio >= 2) * @type {boolean} * @public * @deprecated since 1.58 use {@link sap.ui.Device.support.retina} instead */ jQuery.support.retina = Device.support.retina; // this is also defined by jquery-mobile-custom.js, but this information is needed earlier jQuery.support.touch = Device.support.touch; /** * Whether the current browser supports (2D) CSS transforms * @type {boolean} * @private * @name jQuery.support.cssTransforms */ jQuery.support.cssTransforms = true; /** * Whether the current browser supports 3D CSS transforms * @type {boolean} * @private * @name jQuery.support.cssTransforms3d */ jQuery.support.cssTransforms3d = true; /** * Whether the current browser supports CSS transitions * @type {boolean} * @private * @name jQuery.support.cssTransitions */ jQuery.support.cssTransitions = true; /** * Whether the current browser supports (named) CSS animations * @type {boolean} * @private * @name jQuery.support.cssAnimations */ jQuery.support.cssAnimations = true; /** * Whether the current browser supports CSS gradients. Note that ANY support for CSS gradients leads to "true" here, no matter what the syntax is. * @type {boolean} * @private * @name jQuery.support.cssGradients */ jQuery.support.cssGradients = true; /** * Whether the current browser supports only prefixed flexible layout properties * @type {boolean} * @private * @name jQuery.support.flexBoxPrefixed */ jQuery.support.flexBoxPrefixed = false; /** * Whether the current browser supports the OLD CSS3 Flexible Box Layout directly or via vendor prefixes * @type {boolean} * @private * @name jQuery.support.flexBoxLayout */ jQuery.support.flexBoxLayout = false; /** * Whether the current browser supports the NEW CSS3 Flexible Box Layout directly or via vendor prefixes * @type {boolean} * @private * @name jQuery.support.newFlexBoxLayout */ jQuery.support.newFlexBoxLayout = true; /** * Whether the current browser supports any kind of Flexible Box Layout directly or via vendor prefixes * @type {boolean} * @private * @name jQuery.support.hasFlexBoxSupport */ jQuery.support.hasFlexBoxSupport = true; }()); /** * Root Namespace for the jQuery plug-in provided by SAP SE. * * @version 1.147.0 * @namespace * @public * @static * @deprecated since 1.58. To avoid usage of global variables in general, please * do not use the jQuery.sap namespace any longer. Most of the jQuery.sap functionalities * are replaced by alternative modules which can be found in the API doc. */ jQuery.sap = jQuery.sap || {}; // namespace already created by jquery.sap.stubs // -------------------------- VERSION ------------------------------------- /** * Returns a Version instance created from the given parameters. * * This function can either be called as a constructor (using <code>new</code>) or as a normal function. * It always returns an immutable Version instance. * * The parts of the version number (major, minor, patch, suffix) can be provided in several ways: * <ul> * <li>Version("1.2.3-SNAPSHOT") - as a dot-separated string. Any non-numerical char or a dot followed * by a non-numerical char starts the suffix portion. Any missing major, * minor or patch versions will be set to 0.</li> * <li>Version(1,2,3,"-SNAPSHOT") - as individual parameters. Major, minor and patch must be integer numbers * or empty, suffix must be a string not starting with digits.</li> * <li>Version([1,2,3,"-SNAPSHOT"]) - as an array with the individual parts. The same type restrictions apply * as before.</li> * <li>Version(otherVersion) - as a Version instance (cast operation). Returns the given instance instead * of creating a new one.</li> * </ul> * * To keep the code size small, this implementation mainly validates the single string variant. * All other variants are only validated to some degree. It is the responsibility of the caller to * provide proper parts. * * @param {int|string|any[]|jQuery.sap.Version} vMajor the major part of the version (int) or any of the single * parameter variants explained above. * @param {int} iMinor the minor part of the version number * @param {int} iPatch the patch part of the version number * @param {string} sSuffix the suffix part of the version number * @return {jQuery.sap.Version} the version object as determined from the parameters * * @class Represents a version consisting of major, minor, patch version and suffix, e.g. '1.2.7-SNAPSHOT'. * * @public * @since 1.15.0 * @alias jQuery.sap.Version * @deprecated since 1.58 use {@link module:sap/base/util/Version} instead */ jQuery.sap.Version = Version; /** * Returns a string representation of this version. * @name jQuery.sap.Version#toString * @return {string} a string representation of this version. * @public * @since 1.15.0 * @function */ /** * Returns the major version part of this version. * @name jQuery.sap.Version#getMajor * @function * @return {int} the major version part of this version * @public * @since 1.15.0 */ /** * Returns the minor version part of this version. * @name jQuery.sap.Version#getMinor * @return {int} the minor version part of this version * @public * @since 1.15.0 * @function */ /** * Returns the patch (or micro) version part of this version. * @name jQuery.sap.Version#getPatch * @return {int} the patch version part of this version * @public * @since 1.15.0 * @function */ /** * Returns the version suffix of this version. * * @name jQuery.sap.Version#getSuffix * @return {string} the version suffix of this version * @public * @since 1.15.0 * @function */ /** * Compares this version with a given one. * * The version with which this version should be compared can be given as a <code>jQuery.sap.Version</code> instance, * as a string (e.g. <code>v.compareto("1.4.5")</code>). Or major, minor, patch and suffix values can be given as * separate parameters (e.g. <code>v.compareTo(1, 4, 5)</code>) or in an array (e.g. <code>v.compareTo([1, 4, 5])</code>). * * @name jQuery.sap.Version#compareTo * @return {int} 0, if the given version is equal to this version, a negative value if the given other version is greater * and a positive value otherwise * @public * @since 1.15.0 * @function */ /** * Checks whether this version is in the range of the given interval (start inclusive, end exclusive). * * The boundaries against which this version should be checked can be given as <code>jQuery.sap.Version</code> * instances (e.g. <code>v.inRange(v1, v2)</code>), as strings (e.g. <code>v.inRange("1.4", "2.7")</code>) * or as arrays (e.g. <code>v.inRange([1,4], [2,7])</code>). * * @name jQuery.sap.Version#inRange * @param {string|any[]|jQuery.sap.Version} vMin the start of the range (inclusive) * @param {string|any[]|jQuery.sap.Version} vMax the end of the range (exclusive) * @return {boolean} <code>true</code> if this version is greater or equal to <code>vMin</code> and smaller * than <code>vMax</code>, <code>false</code> otherwise. * @public * @since 1.15.0 * @function */ /** * Returns a high resolution timestamp in microseconds if supported by the environment, otherwise in milliseconds. * The timestamp is based on 01/01/1970 00:00:00 (UNIX epoch) as float with microsecond precision or * with millisecond precision, if high resolution timestamps are not available. * The fractional part of the timestamp represents fractions of a millisecond. * Converting to a <code>Date</code> is possible by using <code>require(["sap/base/util/now"], function(now){new Date(now());}</code> * * @returns {float} timestamp in microseconds if supported by the environment otherwise in milliseconds * @public * @function * @deprecated since 1.58 use {@link module:sap/base/util/now} instead */ jQuery.sap.now = now; /** * Reads the value for the given key from the localStorage or writes a new value to it. * @deprecated Since 1.120 */ var fnMakeLocalStorageAccessor = function(key, type, callback) { return function(value) { try { if ( value != null || type === 'string' ) { if (value) { localStorage.setItem(key, type === 'boolean' ? 'X' : value); } else { localStorage.removeItem(key); } callback(value); } value = localStorage.getItem(key); return type === 'boolean' ? value === 'X' : value; } catch (e) { Log.warning("Could not access localStorage while accessing '" + key + "' (value: '" + value + "', are cookies disabled?): " + e.message); } }; }; /** * @deprecated Since 1.120 */ jQuery.sap.debug = fnMakeLocalStorageAccessor.call(this, 'sap-ui-debug', '', function(vDebugInfo) { /*eslint-disable no-alert */ alert("Usage of debug sources is " + (vDebugInfo ? "on" : "off") + " now.\nFor the change to take effect, you need to reload the page."); /*eslint-enable no-alert */ }); /** * Sets the URL to reboot this app from, the next time it is started. Only works with localStorage API available * (and depending on the browser, if cookies are enabled, even though cookies are not used). * * @param {string} sRebootUrl the URL to sap-ui-core.js, from which the application should load UI5 on next restart; undefined clears the restart URL * @returns {string|undefined} the current reboot URL or undefined in case of an error or when the reboot URL has been cleared * * @private * @function * @deprecated since 1.58 */ jQuery.sap.setReboot = fnMakeLocalStorageAccessor.call(this, 'sap-ui-reboot-URL', 'string', function(sRebootUrl) { // null-ish clears the reboot request if ( sRebootUrl ) { /*eslint-disable no-alert */ alert("Next time this app is launched (only once), it will load UI5 from:\n" + sRebootUrl + ".\nPlease reload the application page now."); /*eslint-enable no-alert */ } }); jQuery.sap.statistics = fnMakeLocalStorageAccessor.call(this, 'sap-ui-statistics', 'boolean', function(bUseStatistics) { /*eslint-disable no-alert */ alert("Usage of Gateway statistics " + (bUseStatistics ? "on" : "off") + " now.\nFor the change to take effect, you need to reload the page."); /*eslint-enable no-alert */ }); // -------------------------- Logging ------------------------------------- /** * Creates a new Logger instance which will use the given component string * for all logged messages without a specific component. * * @name jQuery.sap.log.Logger * @param {string} sDefaultComponent The component to use * @class A Logger class * @since 1.1.2 * @public * @deprecated since 1.58 use {@link module:sap/base/Log.getLogger} instead */ /** * Creates a new fatal-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log instance for method chaining * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#fatal * @function */ /** * Creates a new error-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log instance * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#error * @function */ /** * Creates a new warning-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log instance * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#warning * @function */ /** * Creates a new info-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log instance * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#info * @function */ /** * Creates a new debug-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log instance * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#debug * @function */ /** * Creates a new trace-level entry in the log with the given message, details and calling component. * * @param {string} sMessage Message text to display * @param {string} [sDetails=''] Details about the message, might be omitted * @param {string} [sComponent=''] Name of the component that produced the log entry * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode. * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>. * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple * immutable JSON object with mostly static and stable content. * @return {jQuery.sap.log.Logger} The log-instance * @public * @SecSink {0 1 2|SECRET} Could expose secret data in logs * @name jQuery.sap.log.Logger#trace * @function */ /** * Defines the maximum <code>jQuery.sap.log.Level</code> of log entries that will be recorded. * Log entries with a higher (less important) log level will be omitted from the log. * When a component name is given, the log level will be configured for that component * only, otherwise the log level for the default component of this logger is set. * For the global logger, the global default level is set. * * <b>Note</b>: Setting a global default log level has no impact on already defined * component log levels. They always override the global default log level. * * @param {jQuery.sap.log.Level} iLogLevel The new log level * @param {string} [sComponent] The log component to set the log level for * @return {jQuery.sap.log.Logger} This logger object to allow method chaining * @public * @name jQuery.sap.log.Logger#setLevel * @function */ /** * Returns the log level currently effective for the given component. * If no component is given or when no level has been configured for a * given component, the log level for the default component of this logger is returned. * * @param {string} [sComponent] Name of the component to retrieve the log level for * @return {int} The log level for the given component or the default log level * @public * @since 1.1.2 * @name jQuery.sap.log.Logger#getLevel * @function */ /** * Checks whether logging is enabled for the given log level, * depending on the currently effective log level for the given component. * * If no component is given, the default component of this logger will be taken into account. * * @param {int} [iLevel=Level.DEBUG] The log level in question * @param {string} [sComponent] Name of the component to check the log level for * @return {boolean} Whether logging is enabled or not * @public * @since 1.13.2 * @name jQuery.sap.log.Logger#isLoggable * @function */ /** * A Logging API for JavaScript. * * Provides methods to manage a client-side log and to create entries in it. Each of the logging methods * {@link jQuery.sap.log.debug}, {@link jQuery.sap.log.info}, {@link jQuery.sap.log.warning}, * {@link jQuery.sap.log.error} and {@link jQuery.sap.log.fatal} creates and records a log entry, * containing a timestamp, a log level, a message with details and a component info. * The log level will be one of {@link jQuery.sap.log.Level} and equals the name of the concrete logging method. * * By using the {@link jQuery.sap.log.setLevel} method, consumers can determine the least important * log level which should be recorded. Less important entries will be filtered out. (Note that higher numeric * values represent less important levels). The initially set level depends on the mode that UI5 is running in. * When the optimized sources are executed, the default level will be {@link jQuery.sap.log.Level.ERROR}. * For normal (debug sources), the default level is {@link jQuery.sap.log.Level.DEBUG}. * * All logging methods allow to specify a <b>component</b>. These components are simple strings and * don't have a special meaning to the UI5 framework. However they can be used to semantically group * log entries that belong to the same software component (or feature). There are two APIs that help * to manage logging for such a component. With <code>{@link jQuery.sap.log.getLogger}(sComponent)</code>, * one can retrieve a logger that automatically adds the given <code>sComponent</code> as component * parameter to each log entry, if no other component is specified. Typically, JavaScript code will * retrieve such a logger once during startup and reuse it for the rest of its lifecycle. * Second, the {@link jQuery.sap.log.Logger#setLevel}(iLevel, sComponent) method allows to set the log level * for a specific component only. This allows a more fine granular control about the created logging entries. * {@link jQuery.sap.log.Logger#getLevel} allows to retrieve the currently effective log level for a given * component. * * {@link jQuery.sap.log.getLogEntries} returns an array of the currently collected log entries. * * Furthermore, a listener can be registered to the log. It will be notified whenever a new entry * is added to the log. The listener can be used for displaying log entries in a separate page area, * or for sending it to some external target (server). * * @since 0.9.0 * @namespace * @public * @borrows jQuery.sap.log.Logger#fatal as fatal * @borrows jQuery.sap.log.Logger#error as error * @borrows jQuery.sap.log.Logger#warning as warning * @borrows jQuery.sap.log.Logger#info as info * @borrows jQuery.sap.log.Logger#debug as debug * @borrows jQuery.sap.log.Logger#trace as trace * @borrows jQuery.sap.log.Logger#getLevel as getLevel * @borrows jQuery.sap.log.Logger#setLevel as setLevel * @borrows jQuery.sap.log.Logger#isLoggable as isLoggable * @deprecated since 1.58 use {@link module:sap/base/Log} instead */ jQuery.sap.log = Object.assign(Log.getLogger(), /** @lends jQuery.sap.log */ { /** * Enumeration of the configurable log levels that a Logger should persist to the log. * * Only if the current LogLevel is higher than the level {@link jQuery.sap.log.Level} of the currently added log entry, * then this very entry is permanently added to the log. Otherwise it is ignored. * @see jQuery.sap.log.Logger#setLevel * @enum {int} * @public * @deprecated since 1.58 use {@link module:sap/base/Log.Level} instead */ Level: Log.Level, /** * Do not log anything * @public * @name jQuery.sap.log.Level.NONE * @type {int} */ /** * Fatal level. Use this for logging unrecoverable situations * @public * @name jQuery.sap.log.Level.FATAL * @type {int} */ /** * Error level. Use this for logging of erroneous but still recoverable situations * @public * @name jQuery.sap.log.Level.ERROR * @type {int} */ /** * Warning level. Use this for logging unwanted but foreseen situations * @public * @name jQuery.sap.log.Level.WARNING * @type {int} */ /** * Info level. Use this for logging information of purely informative nature * @public * @name jQuery.sap.log.Level.INFO * @type {int} */ /** * Debug level. Use this for logging information necessary for debugging * @public * @name jQuery.sap.log.Level.DEBUG * @type {int} */ /** * Trace level. Use this for tracing the program flow. * @public * @name jQuery.sap.log.Level.TRACE * @type {int} */ /** * Trace level to log everything. * @public * @name jQuery.sap.log.Level.ALL * @type {int} */ /** * Returns a {@link jQuery.sap.log.Logger} for the given component. * * The method might or might not return the same logger object across multiple calls. * While loggers are assumed to be light weight objects, consumers should try to * avoid redundant calls and instead keep references to already retrieved loggers. * * The optional second parameter <code>iDefaultLogLevel</code> allows to specify * a default log level for the component. It is only applied when no log level has been * defined so far for that component (ignoring inherited log levels). If this method is * called multiple times for the same component but with different log levels, * only the first call one might be taken into account. * * @param {string} sComponent Component to create the logger for * @param {int} [iDefaultLogLevel] a default log level to be used for the component, * if no log level has been defined for it so far. * @return {jQuery.sap.log.Logger} A logger for the component. * @public * @static * @since 1.1.2 * @function */ getLogger: Log.getLogger, /** * Returns the logged entries recorded so far as an array. * * Log entries are plain JavaScript objects with the following properties * <ul> * <li>timestamp {number} point in time when the entry was created</li> * <li>level {int} LogLevel level of the entry</li> * <li>message {string} message text of the entry</li> * </ul> * * @return {object[]} an array containing the recorded log entries * @public * @static * @since 1.1.2 * @function */ getLogEntries: Log.getLogEntries, /** * Allows to add a new LogListener that will be notified for new log entries. * * The given object must provide method <code>onLogEntry</code> and can also be informed * about <code>onDetachFromLog</code> and <code>onAttachToLog</code> * @param {object} oListener The new listener object that should be informed * @return {jQuery.sap.log} The global logger * @public * @static * @function */ addLogListener: Log.addLogListener, /** * Allows to remove a registered LogListener. * @param {object} oListener The new listener object that should be removed * @return {jQuery.sap.log} The global logger * @public * @static * @function */ removeLogListener: Log.removeLogListener, /** * Enables or disables whether additional support information is logged in a trace. * If enabled, logging methods like error, warning, info and debug are calling the additional * optional callback parameter fnSupportInfo and store the returned object in the log entry property supportInfo. * * @param {boolean} bEnabled true if the support information should be logged * @private * @static * @since 1.46.0 * @function */ logSupportInfo: Log.logSupportInfo, /** * Enumeration of levels that can be used in a call to {@link jQuery.sap.log.Logger#setLevel}(iLevel, sComponent). * * @deprecated Since 1.1.2. To streamline the Logging API a bit, the separation between Level and LogLevel has been given up. * Use the (enriched) enumeration {@link jQuery.sap.log.Level} instead. * @enum * @public */ LogLevel: Log.Level, /** * Retrieves the currently recorded log entries. * @deprecated Since 1.1.2. To avoid confusion with getLogger, this method has been renamed to {@link jQuery.sap.log.getLogEntries}. * @function * @public */ getLog: Log.getLogEntries }); var sWindowName = (typeof window === "undefined" || window.top == window) ? "" : "[" + window.location.pathname.split('/').slice(-1)[0] + "] "; /** * A simple assertion mechanism that logs a message when a given condition is not met. * * <b>Note:</b> Calls to this method might be removed when the JavaScript code * is optimized during build. Therefore, callers should not rely on any side effects * of this method. * * @param {boolean} bResult Result of the checked assertion * @param {string|function} vMessage Message that will be logged when the result is <code>false</code>. In case this is a function, the return value of the function will be displayed. This can be used to execute complex code only if the assertion fails. * * @public * @static * @SecSink {1|SECRET} Could expose secret data in logs * @function * @deprecated since 1.58 use {@link module:sap/base/assert} instead */ jQuery.sap.assert = function(bResult, vMessage) { if (!bResult) { var sMessage = typeof vMessage === "function" ? vMessage() : vMessage; assert(bResult, sWindowName + sMessage); } }; // ------------------------------------------- OBJECT -------------------------------------------------------- /** * Returns a new constructor function that creates objects with * the given prototype. * * As of 1.45.0, this method has been deprecated. Use the following code pattern instead: * <pre> * function MyFunction() { * }; * MyFunction.prototype = oPrototype; * </pre> * @param {object} oPrototype Prototype to use for the new objects * @return {function} the newly created constructor function * @public * @static * @deprecated As of 1.45.0, define your own function and assign <code>oPrototype</code> to its <code>prototype</code> property instead. */ jQuery.sap.factory = function factory(oPrototype) { jQuery.sap.assert(typeof oPrototype == "object", "oPrototype must be an object (incl. null)"); function Factory() {} Factory.prototype = oPrototype; return Factory; }; /** * Returns a new object which has the given <code>oPrototype</code> as its prototype. * * If several objects with the same prototype are to be created, * {@link jQuery.sap.factory} should be used instead. * * @param {object} oPrototype Prototype to use for the new object * @return {object} new object * @public * @static * @deprecated As of 1.45.0, use <code>Object.create(oPrototype)</code> instead. */ jQuery.sap.newObject = function newObject(oPrototype) { jQuery.sap.assert(typeof oPrototype == "object", "oPrototype must be an object (incl. null)"); // explicitly fall back to null for best compatibility with old implementation return Object.create(oPrototype || null); }; /** * Returns a new function that returns the given <code>oValue</code> (using its closure). * * Avoids the need for a dedicated member for the value. * * As closures don't come for free, this function should only be used when polluting * the enclosing object is an absolute "must-not" (as it is the case in public base classes). * * @param {object} oValue The value that the getter should return * @returns {function} The new getter function * @public * @static * @function * @deprecated as of version 1.58. Use native JavaScript instead. */ jQuery.sap.getter = function(oValue) { return function() { return oValue; }; }; /** * Returns a JavaScript object which is identified by a sequence of names. * * A call to <code>getObject("a.b.C")</code> has essentially the same effect * as accessing <code>window.a.b.C</code> but with the difference that missing * intermediate objects (a or b in the example above) don't lead to an exception. * * When the addressed object exists, it is simply returned. If it doesn't exists, * the behavior depends on the value of the second, optional parameter * <code>iNoCreates</code> (assuming 'n' to be the number of names in the name sequence): * <ul> * <li>NaN: if iNoCreates is not a number and the addressed object doesn't exist, * then <code>getObject()</code> returns <code>undefined</code>. * <li>0 &lt; iNoCreates &lt; n: any non-existing intermediate object is created, except * the <i>last</i> <code>iNoCreates</code> ones. * </ul> * * Example: * <pre> * getObject() -- returns the context object (either param or window) * getObject("a.b.C") -- will only try to get a.b.C and return undefined if not found. * getObject("a.b.C", 0) -- will create a, b, and C in that order if they don't exists * getObject("a.b.c", 1) -- will create a and b, but not C. * </pre> * * When a <code>oContext</code> is given, the search starts in that object. * Otherwise it starts in the <code>window</code> object that this plugin * has been created in. * * Note: Although this method internally uses <code>object["key"]</code> to address object * properties, it does not support all possible characters in a name. * Especially the dot ('.') is not supported in the individual name segments, * as it is always interpreted as a name separator. * * @param {string} sName a dot separated sequence of names that identify the required object * @param {int} [iNoCreates=NaN] number of objects (from the right) that should not be created * @param {object} [oContext=window] the context to execute the search in * @returns {function} The value of the named object * * @public * @static * @deprecated since 1.58 use {@link module:sap/base/util/ObjectPath.get} or * {@link module:sap/base/util/ObjectPath.set} instead */ jQuery.sap.getObject = function(sName, iNoCreates, oContext) { var oObject = oContext || window, aNames = (sName || "").split("."), l = aNames.length, iEndCreate = isNaN(iNoCreates) ? 0 : l - iNoCreates, i; if ( sap.ui.loader._.getSyncCallBehavior() && oContext === window ) { Log.error("[nosync] getObject called to retrieve global name '" + sName + "'"); } for (i = 0; oObject && i < l; i++) { if (!oObject[aNames[i]] && i < iEndCreate ) { oObject[aNames[i]] = {}; } oObject = oObject[aNames[i]]; } return oObject; }; /** * Sets an object property to a given value, where the property is * identified by a sequence of names (path). * * When a <code>oContext</code> is given, the path starts in that object. * Otherwise it starts in the <code>window</code> object that this plugin * has been created for. * * Note: Although this method internally uses <code>object["key"]</code> to address object * properties, it does not support all possible characters in a name. * Especially the dot ('.') is not supported in the individual name segments, * as it is always interpreted as a name separator. * * @param {string} sName a dot separated sequence of names that identify the property * @param {any} vValue value to be set, can have any type * @param {object} [oContext=window] the context to execute the search in * @public * @static * @deprecated since 1.58 use {@link module:sap/base/util/ObjectPath.set} instead */ jQuery.sap.setObject = function (sName, vValue, oContext) { var oObject = oContext || window, aNames = (sName || "").split("."), l = aNames.length, i; if ( l > 0 ) { for (i = 0; oObject && i < l - 1; i++) { if (!oObject[aNames[i]] ) { oObject[aNames[i]] = {}; } oObject = oObject[aNames[i]]; } oObject[aNames[l - 1]] = vValue; } }; // ---------------------- performance measurement ----------------------------------------------------------- /** * Namespace for the jQuery performance measurement plug-in provided by SAP SE. * * @name jQuery.sap.measure * @namespace * @public * @static * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement} or {@link module:sap/ui/performance/trace/Interaction} instead */ jQuery.sap.measure = Measurement; /** * Gets the current state of the performance measurement functionality * * @name jQuery.sap.measure.getActive * @function * @return {boolean} current state of the performance measurement functionality * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getActive} instead */ /** * Activates or deactivates the performance measure functionality * Optionally a category or list of categories can be passed to restrict measurements to certain categories * like "javascript", "require", "xmlhttprequest", "render" * @param {boolean} bOn - state of the performance measurement functionality to set * @param {string | string[]} aCategories - An optional list of categories that should be measured * * @return {boolean} current state of the performance measurement functionality * @name jQuery.sap.measure#setActive * @function * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.setActive} instead */ /** * Starts a performance measure. * Optionally a category or list of categories can be passed to allow filtering of measurements. * * @name jQuery.sap.measure.start * @function * @param {string} sId ID of the measurement * @param {string} sInfo Info for the measurement * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure * * @return {object} current measurement containing id, info and start-timestamp (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.start} instead */ /** * Pauses a performance measure * * @name jQuery.sap.measure.pause * @function * @param {string} sId ID of the measurement * @return {object} current measurement containing id, info and start-timestamp, pause-timestamp (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.pause} instead */ /** * Resumes a performance measure * * @name jQuery.sap.measure.resume * @function * @param {string} sId ID of the measurement * @return {object} current measurement containing id, info and start-timestamp, resume-timestamp (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.resume} instead */ /** * Ends a performance measure * * @name jQuery.sap.measure.end * @function * @param {string} sId ID of the measurement * @return {object} current measurement containing id, info and start-timestamp, end-timestamp, time, duration (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.end} instead */ /** * Clears all performance measurements * * @name jQuery.sap.measure.clear * @function * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.clear} instead */ /** * Removes a performance measure * * @name jQuery.sap.measure.remove * @function * @param {string} sId ID of the measurement * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.remove} instead */ /** * Adds a performance measurement with all data * This is useful to add external measurements (e.g. from a backend) to the common measurement UI * * @name jQuery.sap.measure.add * @function * @param {string} sId ID of the measurement * @param {string} sInfo Info for the measurement * @param {int} iStart start timestamp * @param {int} iEnd end timestamp * @param {int} iTime time in milliseconds * @param {int} iDuration effective time in milliseconds * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure * @return {object} [] current measurement containing id, info and start-timestamp, end-timestamp, time, duration, categories (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.add} instead */ /** * Starts an average performance measure. * The duration of this measure is an avarage of durations measured for each call. * Optionally a category or list of categories can be passed to allow filtering of measurements. * * @name jQuery.sap.measure.average * @function * @param {string} sId ID of the measurement * @param {string} sInfo Info for the measurement * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure * @return {object} current measurement containing id, info and start-timestamp (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.average} instead */ /** * Gets a performance measure * * @name jQuery.sap.measure.getMeasurement * @function * @param {string} sId ID of the measurement * @return {object} current measurement containing id, info and start-timestamp, end-timestamp, time, duration (false if error) * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getMeasurement} instead */ /** * Gets all performance measurements * * @name jQuery.sap.measure.getAllMeasurements * @function * @param {boolean} [bCompleted] Whether only completed measurements should be returned, if explicitly set to false only incomplete measurements are returned * @return {object[]} current array with measurements containing id, info and start-timestamp, end-timestamp, time, duration, categories * @public * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getAllMeasurements} instead */ /** * Gets all performance measurements where a provided filter function returns a truthy value. * If neither a filter function nor a category is provided an empty array is returned. * To filter for certain properties of measurements a fnFilter can be implemented like this * <code> * function(oMeasurement) { * return oMeasurement.duration > 50; * }</code> * * @name jQuery.sap.measure.filterMeasurements * @function * @param {function} [fnFilter] a filter function that returns true if the passed measurement should be added to the result * @param {boolean|undefined} [bCompleted] Optional parameter to determine if either completed or incomplete measurements should be returned (both if not set or undefined) * @param {string[]} [aCategories] The function returns only measurements which match these specified categories * * @return {object} [] filtered array with measurements containing id, info and start-timestamp, end-timestamp, time, duration, categories (false if error) * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.filterMeasurements} instead */ /** * Registers an average measurement for a given objects method * * @name jQuery.sap.measure.registerMethod * @function * @param {string} sId the id of the measurement * @param {object} oObject the object of the method * @param {string} sMethod the name of the method * @param {string[]} [aCategories = ["javascript"]] An optional categories list for the measurement * * @returns {boolean} true if the registration was successful * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.registerMethod} instead */ /** * Unregisters an average measurement for a given objects method * * @name jQuery.sap.measure.unregisterMethod * @function * @param {string} sId the id of the measurement * @param {object} oObject the object of the method * @param {string} sMethod the name of the method * * @returns {boolean} true if the unregistration was successful * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.unregisterMethod} instead */ /** * Unregisters all average measurements * * @name jQuery.sap.measure.unregisterAllMethods * @function * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.unregisterAllMethods} instead */ /** * Clears all interaction measurements * * @function * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.clear} instead */ jQuery.sap.measure.clearInteractionMeasurements = () => { Interaction.clear(); }; /** * Start an interaction measurements * * @function * @param {string} sType type of the event which triggered the interaction * @param {object} oSrcElement the control on which the interaction was triggered * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.start} instead */ jQuery.sap.measure.startInteraction = (sType, oSrcElement) => { Interaction.start(sType, oSrcElement); }; /** * End an interaction measurements * * @function * @param {boolean} bForce forces end of interaction now and ignores further re-renderings * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.end} instead */ jQuery.sap.measure.endInteraction = (bForce) => { Interaction.end(bForce); }; /** * Gets the incomplete pending interaction * @function * @return {object} interaction measurement * @private * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.getPending} instead */ jQuery.sap.measure.getPendingInteractionMeasurement = () => { return Interaction.getPending(); }; /** * Gets all interaction measurements for which a provided filter function returns a truthy value. * To filter for certain categories of measurements a fnFilter can be implemented like this * <code> * function(InteractionMeasurement) { * return InteractionMeasurement.duration > 0 * }</code> * * @function * @param {function} fnFilter a filter function that returns true if the passed measurement should be added to the result * @return {object[]} all interaction measurements passing the filter function successfully * @public * @since 1.36.2 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.filter} instead */ jQuery.sap.measure.filterInteractionMeasurements = (fnFilter) => { return Interaction.filter(fnFilter); }; /** * Gets all interaction measurements * @function * @param {boolean} bFinalize finalize the current pending interaction so that it is contained in the returned array * @return {object[]} all interaction measurements * @public * @since 1.34.0 * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.getAll} instead */ jQuery.sap.measure.getAllInteractionMeasurements = (bFinalize) => { return Interaction.getAll(bFinalize); }; /** * Gets the current request timings array for type 'resource' safely * * @function * @return {object[]} array of performance timing objects * @public * @since 1.34.0 * @deprecated since 1.58 use native function <code>performance.getEntriesByType("resource")</code> instead */ jQuery.sap.measure.getRequestTimings = function() { if (performance.getEntriesByType) { return performance.getEntriesByType("resource"); } return []; }; /** * Clears all request timings safely. * * @function * @public * @since 1.34.0 * @deprecated since 1.58 use native function <code>performance.clearResourceTimings()</code> where available */ jQuery.sap.measure.clearRequestTimings = function() { if (performance.clearResourceTimings) { performance.clearResourceTimings(); } }; /** * Sets the request buffer size for the measurement safely. * * @param {int} iSize size of the buffer * @function * @public * @since 1.34.0 * @deprecated since 1.58 use native function <code>performance.setResourceTimingBufferSize(iSize)</code> where available */ jQuery.sap.measure.setRequestBufferSize = function(iSize) { if (performance.setResourceTimingBufferSize) { performance.setResourceTimingBufferSize(iSize); } }; // ---------------------- require/declare -------------------------------------------------------- /** * @deprecated As of Version 1.120.0 */ (function() { var mKnownSubtypes = LoaderExtensions.getKnownSubtypes(), rSubTypes; (function() { var sSub = ""; for (var sType in mKnownSubtypes) { sSub = (sSub ? sSub + "|" : "") + "(?:(?:" + mKnownSubtypes[sType].join("\\.|") + "\\.)?" + sType + ")"; } sSub = "\\.(?:" + sSub + "|[^./]+)$"; rSubTypes = new RegExp(sSub); }()); function ui5ToRJS(sName) { if ( /^jquery\.sap\./.test(sName) ) { return sName; } return sName.replace(/\./g, "/"); } /** * Constructs a URL to load the module with the given name and file type (suffix). * * Searches the longest prefix of the given module name for which a registration * exists (see {@link jQuery.sap.registerModulePath}) and replaces that prefix * by the registered URL prefix. * * The remainder of the module name is appended to th