1 | /*!
|
2 | * OpenUI5
|
3 | * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
|
4 | * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5 | */
|
6 |
|
7 | /*global XMLHttpRequest, localStorage, alert, confirm, console, document, Promise */
|
8 |
|
9 | /**
|
10 | * Provides base functionality of the SAP jQuery plugin as extension of the jQuery framework.<br/>
|
11 | * See also <a href="http://api.jquery.com/jQuery/">jQuery</a> for details.<br/>
|
12 | * Although these functions appear as static ones, they are meant to be used on jQuery instances.<br/>
|
13 | * If not stated differently, the functions follow the fluent interface paradigm and return the jQuery instance for chaining of statements.
|
14 | *
|
15 | * Example for usage of an instance method:
|
16 | * <pre>
|
17 | * var oRect = jQuery("#myDiv").rect();
|
18 | * alert("Top Position: " + oRect.top);
|
19 | * </pre>
|
20 | *
|
21 | * @namespace jQuery
|
22 | * @public
|
23 | */
|
24 | sap.ui.define([
|
25 | // new sap/base/* modules
|
26 | "sap/base/util/now", "sap/base/util/Version", "sap/base/assert", "sap/base/Log",
|
27 |
|
28 | // new sap/ui/* modules
|
29 | "sap/ui/dom/getComputedStyleFix", "sap/ui/dom/includeScript",
|
30 | "sap/ui/dom/includeStylesheet", "sap/ui/core/support/Hotkeys", "sap/ui/test/RecorderHotkeyListener",
|
31 | "sap/ui/security/FrameOptions", "sap/ui/performance/Measurement", "sap/ui/performance/trace/Interaction",
|
32 | "sap/ui/base/syncXHRFix", "sap/base/util/LoaderExtensions",
|
33 |
|
34 | // former sap-ui-core.js dependencies
|
35 | "sap/ui/Device",
|
36 |
|
37 | "sap/ui/thirdparty/jquery",
|
38 | "sap/ui/thirdparty/jqueryui/jquery-ui-position",
|
39 | "ui5loader-autoconfig",
|
40 | "jquery.sap.stubs",
|
41 | "sap/ui/thirdparty/URI", // side effect: make global URI available
|
42 | "sap/ui/events/PasteEventFix" // side effect: activates paste event fix
|
43 | ], function(now, Version, assert, Log,
|
44 |
|
45 | getComputedStyleFix, includeScript,
|
46 | includeStylesheet, SupportHotkeys, TestRecorderHotkeyListener,
|
47 | FrameOptions, Measurement, Interaction,
|
48 | syncXHRFix, LoaderExtensions,
|
49 |
|
50 | Device,
|
51 |
|
52 | jQuery /*, jqueryUiPosition, ui5loaderAutoconfig, jquerySapStubs, URI, PasteEventFix */) {
|
53 | ;
|
54 |
|
55 | if ( !jQuery ) {
|
56 | throw new Error("Loading of jQuery failed");
|
57 | }
|
58 |
|
59 | var ui5loader = sap.ui.loader;
|
60 |
|
61 | if ( !ui5loader || !ui5loader._ ) {
|
62 | throw new Error("The UI5 compatilbility module requires a UI5 specific AMD implementation");
|
63 | }
|
64 |
|
65 | var _ui5loader = ui5loader._;
|
66 |
|
67 | // early logging support
|
68 | var _earlyLogs = [];
|
69 | function _earlyLog(sLevel, sMessage) {
|
70 | _earlyLogs.push({
|
71 | level: sLevel,
|
72 | message: sMessage
|
73 | });
|
74 | }
|
75 |
|
76 | var oJQVersion = Version(jQuery.fn.jquery);
|
77 |
|
78 | (function() {
|
79 | /**
|
80 | * Holds information about the browser's capabilities and quirks.
|
81 | * This object is provided and documented by jQuery.
|
82 | * But it is extended by SAPUI5 with detection for features not covered by jQuery. This documentation ONLY covers the detection properties added by UI5.
|
83 | * For the standard detection properties, please refer to the jQuery documentation.
|
84 | *
|
85 | * These properties added by UI5 are only available temporarily until jQuery adds feature detection on their own.
|
86 | *
|
87 | * @name jQuery.support
|
88 | * @namespace
|
89 | * @private
|
90 | * @deprecated since 1.58 use {@link sap.ui.Device} instead
|
91 | */
|
92 | jQuery.support = jQuery.support || {};
|
93 |
|
94 | /**
|
95 | * Whether the device has a retina display (window.devicePixelRatio >= 2)
|
96 | * @type {boolean}
|
97 | * @public
|
98 | * @deprecated since 1.58 use {@link sap.ui.Device.support.retina} instead
|
99 | */
|
100 | jQuery.support.retina = Device.support.retina;
|
101 |
|
102 | // this is also defined by jquery-mobile-custom.js, but this information is needed earlier
|
103 | jQuery.support.touch = Device.support.touch;
|
104 |
|
105 | /**
|
106 | * Whether the current browser supports (2D) CSS transforms
|
107 | * @type {boolean}
|
108 | * @private
|
109 | * @name jQuery.support.cssTransforms
|
110 | */
|
111 | jQuery.support.cssTransforms = true;
|
112 |
|
113 | /**
|
114 | * Whether the current browser supports 3D CSS transforms
|
115 | * @type {boolean}
|
116 | * @private
|
117 | * @name jQuery.support.cssTransforms3d
|
118 | */
|
119 | jQuery.support.cssTransforms3d = true;
|
120 |
|
121 | /**
|
122 | * Whether the current browser supports CSS transitions
|
123 | * @type {boolean}
|
124 | * @private
|
125 | * @name jQuery.support.cssTransitions
|
126 | */
|
127 | jQuery.support.cssTransitions = true;
|
128 |
|
129 | /**
|
130 | * Whether the current browser supports (named) CSS animations
|
131 | * @type {boolean}
|
132 | * @private
|
133 | * @name jQuery.support.cssAnimations
|
134 | */
|
135 | jQuery.support.cssAnimations = true;
|
136 |
|
137 | /**
|
138 | * Whether the current browser supports CSS gradients. Note that ANY support for CSS gradients leads to "true" here, no matter what the syntax is.
|
139 | * @type {boolean}
|
140 | * @private
|
141 | * @name jQuery.support.cssGradients
|
142 | */
|
143 | jQuery.support.cssGradients = true;
|
144 |
|
145 | /**
|
146 | * Whether the current browser supports only prefixed flexible layout properties
|
147 | * @type {boolean}
|
148 | * @private
|
149 | * @name jQuery.support.flexBoxPrefixed
|
150 | */
|
151 | jQuery.support.flexBoxPrefixed = false;
|
152 |
|
153 | /**
|
154 | * Whether the current browser supports the OLD CSS3 Flexible Box Layout directly or via vendor prefixes
|
155 | * @type {boolean}
|
156 | * @private
|
157 | * @name jQuery.support.flexBoxLayout
|
158 | */
|
159 | jQuery.support.flexBoxLayout = false;
|
160 |
|
161 | /**
|
162 | * Whether the current browser supports the NEW CSS3 Flexible Box Layout directly or via vendor prefixes
|
163 | * @type {boolean}
|
164 | * @private
|
165 | * @name jQuery.support.newFlexBoxLayout
|
166 | */
|
167 | jQuery.support.newFlexBoxLayout = true;
|
168 |
|
169 | /**
|
170 | * Whether the current browser supports any kind of Flexible Box Layout directly or via vendor prefixes
|
171 | * @type {boolean}
|
172 | * @private
|
173 | * @name jQuery.support.hasFlexBoxSupport
|
174 | */
|
175 | jQuery.support.hasFlexBoxSupport = true;
|
176 | }());
|
177 |
|
178 | // getComputedStyle polyfill for firefox
|
179 | if ( Device.browser.firefox ) {
|
180 | getComputedStyleFix();
|
181 | }
|
182 |
|
183 | // XHR proxy for Firefox
|
184 | if ( Device.browser.firefox && window.Proxy ) {
|
185 | syncXHRFix();
|
186 | }
|
187 |
|
188 | /*
|
189 | * Merged, raw (un-interpreted) configuration data from the following sources
|
190 | * (last one wins)
|
191 | * <ol>
|
192 | * <li>global configuration object <code>window["sap-ui-config"]</code> (could be either a string/url or a conffiguration object)</li>
|
193 | * <li><code>data-sap-ui-config</code> attribute of the bootstrap script tag</li>
|
194 | * <li>other <code>data-sap-ui-<i>xyz</i></code> attributes of the bootstrap tag</li>
|
195 | * </ol>
|
196 | */
|
197 | var oCfgData = window["sap-ui-config"] = (function() {
|
198 | function normalize(o) {
|
199 | for (var i in o) {
|
200 | var v = o[i];
|
201 | var il = i.toLowerCase();
|
202 | if ( !o.hasOwnProperty(il) ) {
|
203 | o[il] = v;
|
204 | delete o[i];
|
205 | }
|
206 | }
|
207 | return o;
|
208 | }
|
209 |
|
210 | function loadExternalConfig(url) {
|
211 | var sCfgFile = "sap-ui-config.json",
|
212 | config;
|
213 |
|
214 | Log.warning("Loading external bootstrap configuration from \"" + url + "\". This is a design time feature and not for productive usage!");
|
215 | if (url !== sCfgFile) {
|
216 | Log.warning("The external bootstrap configuration file should be named \"" + sCfgFile + "\"!");
|
217 | }
|
218 |
|
219 | var xhr = new XMLHttpRequest();
|
220 | xhr.addEventListener('load', function(e) {
|
221 | if ( xhr.status === 200 && xhr.responseText ) {
|
222 | try {
|
223 | config = JSON.parse( xhr.responseText );
|
224 | } catch (error) {
|
225 | Log.error("Parsing externalized bootstrap configuration from \"" + url + "\" failed! Reason: " + error + "!");
|
226 | }
|
227 | } else {
|
228 | Log.error("Loading externalized bootstrap configuration from \"" + url + "\" failed! Response: " + xhr.status + "!");
|
229 | }
|
230 | });
|
231 | xhr.open('GET', url, false);
|
232 | try {
|
233 | xhr.send();
|
234 | } catch (error) {
|
235 | Log.error("Loading externalized bootstrap configuration from \"" + url + "\" failed! Reason: " + error + "!");
|
236 | }
|
237 |
|
238 | config = config || {};
|
239 | config.__loaded = true; // mark config as 'being loaded', needed to detect sync call
|
240 |
|
241 | return config;
|
242 | }
|
243 |
|
244 | function getInfo() {
|
245 | function check(oScript, rUrlPattern) {
|
246 | var sUrl = oScript && oScript.getAttribute("src");
|
247 | var oMatch = rUrlPattern.exec(sUrl);
|
248 | if ( oMatch ) {
|
249 | return {
|
250 | tag: oScript,
|
251 | url: sUrl,
|
252 | resourceRoot: oMatch[1] || ""
|
253 | };
|
254 | }
|
255 | }
|
256 |
|
257 | var rResources = /^((?:.*\/)?resources\/)/,
|
258 | rBootScripts, aScripts, i, oResult;
|
259 |
|
260 | // Prefer script tags which have the sap-ui-bootstrap ID
|
261 | // This prevents issues when multiple script tags point to files named
|
262 | // "sap-ui-core.js", for example when using the cache buster for UI5 resources
|
263 | oResult = check(document.querySelector('SCRIPT[src][id=sap-ui-bootstrap]'), rResources);
|
264 |
|
265 | if ( !oResult ) {
|
266 | aScripts = document.querySelectorAll('SCRIPT[src]');
|
267 | rBootScripts = /^([^?#]*\/)?(?:sap-ui-(?:core|custom|boot|merged)(?:-[^?#/]*)?|jquery.sap.global|ui5loader(?:-autoconfig)?)\.js(?:[?#]|$)/;
|
268 | for ( i = 0; i < aScripts.length; i++ ) {
|
269 | oResult = check(aScripts[i], rBootScripts);
|
270 | if ( oResult ) {
|
271 | break;
|
272 | }
|
273 | }
|
274 | }
|
275 |
|
276 | return oResult || {};
|
277 | }
|
278 |
|
279 | var _oBootstrap = getInfo(),
|
280 | oScriptTag = _oBootstrap.tag,
|
281 | oCfg = window["sap-ui-config"];
|
282 |
|
283 | // load the configuration from an external JSON file
|
284 | if (typeof oCfg === "string") {
|
285 | oCfg = loadExternalConfig(oCfg);
|
286 | }
|
287 |
|
288 | oCfg = normalize(oCfg || {});
|
289 | oCfg.resourceroots = oCfg.resourceroots || {};
|
290 | oCfg.themeroots = oCfg.themeroots || {};
|
291 |
|
292 | // map loadall mode to sync preload mode
|
293 | if ( /(^|\/)(sap-?ui5|[^\/]+-all).js([?#]|$)/.test(_oBootstrap.url) ) {
|
294 | Log.error(
|
295 | "The all-in-one file 'sap-ui-core-all.js' has been abandoned in favour of standard preloads." +
|
296 | " Please migrate to sap-ui-core.js and consider to use async preloads.");
|
297 | oCfg.preload = 'sync';
|
298 | }
|
299 |
|
300 | // if a script tag has been identified, collect its configuration info
|
301 | if ( oScriptTag ) {
|
302 | // evaluate the config attribute first - if present
|
303 | var sConfig = oScriptTag.getAttribute("data-sap-ui-config");
|
304 | if ( sConfig ) {
|
305 | try {
|
306 | var oParsedConfig;
|
307 | try {
|
308 | // first try to parse the config as a plain JSON
|
309 | oParsedConfig = JSON.parse("{" + sConfig + "}");
|
310 | } catch (e) {
|
311 | // if the JSON.parse fails, we fall back to the more lenient "new Function" eval for compatibility reasons
|
312 | Log.error("JSON.parse on the data-sap-ui-config attribute failed. Please check the config for JSON syntax violations.");
|
313 | /*eslint-disable no-new-func */
|
314 | oParsedConfig = (new Function("return {" + sConfig + "};"))();
|
315 | /*eslint-enable no-new-func */
|
316 | }
|
317 | Object.assign(oCfg, normalize(oParsedConfig));
|
318 | } catch (e) {
|
319 | // no log yet, how to report this error?
|
320 | Log.error("failed to parse data-sap-ui-config attribute: " + (e.message || e));
|
321 | }
|
322 | }
|
323 |
|
324 | // merge with any existing "data-sap-ui-" attributes
|
325 | for (var i = 0; i < oScriptTag.attributes.length; i++) {
|
326 | var attr = oScriptTag.attributes[i];
|
327 | var m = attr.name.match(/^data-sap-ui-(.*)$/);
|
328 | if ( m ) {
|
329 | // the following (deactivated) conversion would implement multi-word names like "resource-roots"
|
330 | m = m[1].toLowerCase(); // .replace(/\-([a-z])/g, function(s,w) { return w.toUpperCase(); })
|
331 | if ( m === 'resourceroots' ) {
|
332 | // merge map entries instead of overwriting map
|
333 | Object.assign(oCfg[m], JSON.parse(attr.value));
|
334 | } else if ( m === 'theme-roots' ) {
|
335 | // merge map entries, but rename to camelCase
|
336 | Object.assign(oCfg.themeroots, JSON.parse(attr.value));
|
337 | } else if ( m !== 'config' ) {
|
338 | oCfg[m] = attr.value;
|
339 | }
|
340 | }
|
341 | }
|
342 | }
|
343 |
|
344 | return oCfg;
|
345 | }());
|
346 |
|
347 | var syncCallBehavior = 0; // ignore
|
348 | if ( oCfgData['xx-nosync'] === 'warn' || /(?:\?|&)sap-ui-xx-nosync=(?:warn)/.exec(window.location.search) ) {
|
349 | syncCallBehavior = 1;
|
350 | }
|
351 | if ( oCfgData['xx-nosync'] === true || oCfgData['xx-nosync'] === 'true' || /(?:\?|&)sap-ui-xx-nosync=(?:x|X|true)/.exec(window.location.search) ) {
|
352 | syncCallBehavior = 2;
|
353 | }
|
354 |
|
355 | ui5loader.config({
|
356 | reportSyncCalls: syncCallBehavior
|
357 | });
|
358 |
|
359 | if ( syncCallBehavior && oCfgData.__loaded ) {
|
360 | _earlyLog(syncCallBehavior === 1 ? "warning" : "error", "[nosync]: configuration loaded via sync XHR");
|
361 | }
|
362 |
|
363 | // check whether noConflict must be used...
|
364 | if ( oCfgData.noconflict === true || oCfgData.noconflict === "true" || oCfgData.noconflict === "x" ) {
|
365 | jQuery.noConflict();
|
366 | }
|
367 |
|
368 | /**
|
369 | * Root Namespace for the jQuery plug-in provided by SAP SE.
|
370 | *
|
371 | * @version 1.90.11
|
372 | * @namespace
|
373 | * @public
|
374 | * @static
|
375 | * @deprecated since 1.58. To avoid usage of global variables in general, please
|
376 | * do not use the jQuery.sap namespace any longer. Most of the jQuery.sap functionalities
|
377 | * are replaced by alternative modules which can be found in the API doc.
|
378 | */
|
379 | jQuery.sap = jQuery.sap || {}; // namespace already created by jquery.sap.stubs
|
380 |
|
381 | // -------------------------- VERSION -------------------------------------
|
382 |
|
383 | /**
|
384 | * Returns a Version instance created from the given parameters.
|
385 | *
|
386 | * This function can either be called as a constructor (using <code>new</code>) or as a normal function.
|
387 | * It always returns an immutable Version instance.
|
388 | *
|
389 | * The parts of the version number (major, minor, patch, suffix) can be provided in several ways:
|
390 | * <ul>
|
391 | * <li>Version("1.2.3-SNAPSHOT") - as a dot-separated string. Any non-numerical char or a dot followed
|
392 | * by a non-numerical char starts the suffix portion. Any missing major,
|
393 | * minor or patch versions will be set to 0.</li>
|
394 | * <li>Version(1,2,3,"-SNAPSHOT") - as individual parameters. Major, minor and patch must be integer numbers
|
395 | * or empty, suffix must be a string not starting with digits.</li>
|
396 | * <li>Version([1,2,3,"-SNAPSHOT"]) - as an array with the individual parts. The same type restrictions apply
|
397 | * as before.</li>
|
398 | * <li>Version(otherVersion) - as a Version instance (cast operation). Returns the given instance instead
|
399 | * of creating a new one.</li>
|
400 | * </ul>
|
401 | *
|
402 | * To keep the code size small, this implementation mainly validates the single string variant.
|
403 | * All other variants are only validated to some degree. It is the responsibility of the caller to
|
404 | * provide proper parts.
|
405 | *
|
406 | * @param {int|string|any[]|jQuery.sap.Version} vMajor the major part of the version (int) or any of the single
|
407 | * parameter variants explained above.
|
408 | * @param {int} iMinor the minor part of the version number
|
409 | * @param {int} iPatch the patch part of the version number
|
410 | * @param {string} sSuffix the suffix part of the version number
|
411 | * @return {jQuery.sap.Version} the version object as determined from the parameters
|
412 | *
|
413 | * @class Represents a version consisting of major, minor, patch version and suffix, e.g. '1.2.7-SNAPSHOT'.
|
414 | *
|
415 | * @public
|
416 | * @since 1.15.0
|
417 | * @alias jQuery.sap.Version
|
418 | * @deprecated since 1.58 use {@link module:sap/base/util/Version} instead
|
419 | */
|
420 | jQuery.sap.Version = Version;
|
421 |
|
422 | /**
|
423 | * Returns a string representation of this version.
|
424 | * @name jQuery.sap.Version#toString
|
425 | * @return {string} a string representation of this version.
|
426 | * @public
|
427 | * @since 1.15.0
|
428 | * @function
|
429 | */
|
430 |
|
431 | /**
|
432 | * Returns the major version part of this version.
|
433 | * @name jQuery.sap.Version#getMajor
|
434 | * @function
|
435 | * @return {int} the major version part of this version
|
436 | * @public
|
437 | * @since 1.15.0
|
438 | */
|
439 |
|
440 | /**
|
441 | * Returns the minor version part of this version.
|
442 | * @name jQuery.sap.Version#getMinor
|
443 | * @return {int} the minor version part of this version
|
444 | * @public
|
445 | * @since 1.15.0
|
446 | * @function
|
447 | */
|
448 |
|
449 | /**
|
450 | * Returns the patch (or micro) version part of this version.
|
451 | * @name jQuery.sap.Version#getPatch
|
452 | * @return {int} the patch version part of this version
|
453 | * @public
|
454 | * @since 1.15.0
|
455 | * @function
|
456 | */
|
457 |
|
458 | /**
|
459 | * Returns the version suffix of this version.
|
460 | *
|
461 | * @name jQuery.sap.Version#getSuffix
|
462 | * @return {string} the version suffix of this version
|
463 | * @public
|
464 | * @since 1.15.0
|
465 | * @function
|
466 | */
|
467 |
|
468 | /**
|
469 | * Compares this version with a given one.
|
470 | *
|
471 | * The version with which this version should be compared can be given as a <code>jQuery.sap.Version</code> instance,
|
472 | * as a string (e.g. <code>v.compareto("1.4.5")</code>). Or major, minor, patch and suffix values can be given as
|
473 | * separate parameters (e.g. <code>v.compareTo(1, 4, 5)</code>) or in an array (e.g. <code>v.compareTo([1, 4, 5])</code>).
|
474 | *
|
475 | * @name jQuery.sap.Version#compareTo
|
476 | * @return {int} 0, if the given version is equal to this version, a negative value if the given other version is greater
|
477 | * and a positive value otherwise
|
478 | * @public
|
479 | * @since 1.15.0
|
480 | * @function
|
481 | */
|
482 |
|
483 | /**
|
484 | * Checks whether this version is in the range of the given interval (start inclusive, end exclusive).
|
485 | *
|
486 | * The boundaries against which this version should be checked can be given as <code>jQuery.sap.Version</code>
|
487 | * instances (e.g. <code>v.inRange(v1, v2)</code>), as strings (e.g. <code>v.inRange("1.4", "2.7")</code>)
|
488 | * or as arrays (e.g. <code>v.inRange([1,4], [2,7])</code>).
|
489 | *
|
490 | * @name jQuery.sap.Version#inRange
|
491 | * @param {string|any[]|jQuery.sap.Version} vMin the start of the range (inclusive)
|
492 | * @param {string|any[]|jQuery.sap.Version} vMax the end of the range (exclusive)
|
493 | * @return {boolean} <code>true</code> if this version is greater or equal to <code>vMin</code> and smaller
|
494 | * than <code>vMax</code>, <code>false</code> otherwise.
|
495 | * @public
|
496 | * @since 1.15.0
|
497 | * @function
|
498 | */
|
499 |
|
500 | /**
|
501 | * Returns a high resolution timestamp in microseconds if supported by the environment, otherwise in milliseconds.
|
502 | * The timestamp is based on 01/01/1970 00:00:00 (UNIX epoch) as float with microsecond precision or
|
503 | * with millisecond precision, if high resolution timestamps are not available.
|
504 | * The fractional part of the timestamp represents fractions of a millisecond.
|
505 | * Converting to a <code>Date</code> is possible by using <code>require(["sap/base/util/now"], function(now){new Date(now());}</code>
|
506 | *
|
507 | * @returns {float} timestamp in microseconds if supported by the environment otherwise in milliseconds
|
508 | * @public
|
509 | * @function
|
510 | * @deprecated since 1.58 use {@link module:sap/base/util/now} instead
|
511 | */
|
512 | jQuery.sap.now = now;
|
513 |
|
514 | // Reads the value for the given key from the localStorage or writes a new value to it.
|
515 | var fnMakeLocalStorageAccessor = function(key, type, callback) {
|
516 | return function(value) {
|
517 | try {
|
518 | if ( value != null || type === 'string' ) {
|
519 | if (value) {
|
520 | localStorage.setItem(key, type === 'boolean' ? 'X' : value);
|
521 | } else {
|
522 | localStorage.removeItem(key);
|
523 | }
|
524 | callback(value);
|
525 | }
|
526 | value = localStorage.getItem(key);
|
527 | return type === 'boolean' ? value === 'X' : value;
|
528 | } catch (e) {
|
529 | Log.warning("Could not access localStorage while accessing '" + key + "' (value: '" + value + "', are cookies disabled?): " + e.message);
|
530 | }
|
531 | };
|
532 | };
|
533 |
|
534 | jQuery.sap.debug = fnMakeLocalStorageAccessor.call(this, 'sap-ui-debug', '', function(vDebugInfo) {
|
535 | /*eslint-disable no-alert */
|
536 | alert("Usage of debug sources is " + (vDebugInfo ? "on" : "off") + " now.\nFor the change to take effect, you need to reload the page.");
|
537 | /*eslint-enable no-alert */
|
538 | });
|
539 |
|
540 | /**
|
541 | * Sets the URL to reboot this app from, the next time it is started. Only works with localStorage API available
|
542 | * (and depending on the browser, if cookies are enabled, even though cookies are not used).
|
543 | *
|
544 | * @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
|
545 | * @returns {string} the current reboot URL or undefined in case of an error or when the reboot URL has been cleared
|
546 | *
|
547 | * @private
|
548 | * @function
|
549 | * @deprecated since 1.58
|
550 | */
|
551 | jQuery.sap.setReboot = fnMakeLocalStorageAccessor.call(this, 'sap-ui-reboot-URL', 'string', function(sRebootUrl) { // null-ish clears the reboot request
|
552 | if ( sRebootUrl ) {
|
553 | /*eslint-disable no-alert */
|
554 | alert("Next time this app is launched (only once), it will load UI5 from:\n" + sRebootUrl + ".\nPlease reload the application page now.");
|
555 | /*eslint-enable no-alert */
|
556 | }
|
557 | });
|
558 |
|
559 | jQuery.sap.statistics = fnMakeLocalStorageAccessor.call(this, 'sap-ui-statistics', 'boolean', function(bUseStatistics) {
|
560 | /*eslint-disable no-alert */
|
561 | alert("Usage of Gateway statistics " + (bUseStatistics ? "on" : "off") + " now.\nFor the change to take effect, you need to reload the page.");
|
562 | /*eslint-enable no-alert */
|
563 | });
|
564 |
|
565 | // -------------------------- Logging -------------------------------------
|
566 |
|
567 | /**
|
568 | * Creates a new Logger instance which will use the given component string
|
569 | * for all logged messages without a specific component.
|
570 | *
|
571 | * @name jQuery.sap.log.Logger
|
572 | * @param {string} sDefaultComponent The component to use
|
573 | * @class A Logger class
|
574 | * @since 1.1.2
|
575 | * @public
|
576 | * @deprecated since 1.58 use {@link module:sap/base/Log.getLogger} instead
|
577 | */
|
578 |
|
579 | /**
|
580 | * Creates a new fatal-level entry in the log with the given message, details and calling component.
|
581 | *
|
582 | * @param {string} sMessage Message text to display
|
583 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
584 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
585 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
586 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
587 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
588 | * immutable JSON object with mostly static and stable content.
|
589 | * @return {jQuery.sap.log.Logger} The log instance for method chaining
|
590 | * @public
|
591 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
592 | * @name jQuery.sap.log.Logger#fatal
|
593 | * @function
|
594 | */
|
595 |
|
596 | /**
|
597 | * Creates a new error-level entry in the log with the given message, details and calling component.
|
598 | *
|
599 | * @param {string} sMessage Message text to display
|
600 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
601 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
602 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
603 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
604 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
605 | * immutable JSON object with mostly static and stable content.
|
606 | * @return {jQuery.sap.log.Logger} The log instance
|
607 | * @public
|
608 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
609 | * @name jQuery.sap.log.Logger#error
|
610 | * @function
|
611 | */
|
612 |
|
613 | /**
|
614 | * Creates a new warning-level entry in the log with the given message, details and calling component.
|
615 | *
|
616 | * @param {string} sMessage Message text to display
|
617 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
618 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
619 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
620 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
621 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
622 | * immutable JSON object with mostly static and stable content.
|
623 | * @return {jQuery.sap.log.Logger} The log instance
|
624 | * @public
|
625 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
626 | * @name jQuery.sap.log.Logger#warning
|
627 | * @function
|
628 | */
|
629 |
|
630 | /**
|
631 | * Creates a new info-level entry in the log with the given message, details and calling component.
|
632 | *
|
633 | * @param {string} sMessage Message text to display
|
634 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
635 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
636 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
637 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
638 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
639 | * immutable JSON object with mostly static and stable content.
|
640 | * @return {jQuery.sap.log.Logger} The log instance
|
641 | * @public
|
642 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
643 | * @name jQuery.sap.log.Logger#info
|
644 | * @function
|
645 | */
|
646 |
|
647 | /**
|
648 | * Creates a new debug-level entry in the log with the given message, details and calling component.
|
649 | *
|
650 | * @param {string} sMessage Message text to display
|
651 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
652 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
653 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
654 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
655 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
656 | * immutable JSON object with mostly static and stable content.
|
657 | * @return {jQuery.sap.log.Logger} The log instance
|
658 | * @public
|
659 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
660 | * @name jQuery.sap.log.Logger#debug
|
661 | * @function
|
662 | */
|
663 |
|
664 | /**
|
665 | * Creates a new trace-level entry in the log with the given message, details and calling component.
|
666 | *
|
667 | * @param {string} sMessage Message text to display
|
668 | * @param {string} [sDetails=''] Details about the message, might be omitted
|
669 | * @param {string} [sComponent=''] Name of the component that produced the log entry
|
670 | * @param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
|
671 | * This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
|
672 | * To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
|
673 | * immutable JSON object with mostly static and stable content.
|
674 | * @return {jQuery.sap.log.Logger} The log-instance
|
675 | * @public
|
676 | * @SecSink {0 1 2|SECRET} Could expose secret data in logs
|
677 | * @name jQuery.sap.log.Logger#trace
|
678 | * @function
|
679 | */
|
680 |
|
681 | /**
|
682 | * Defines the maximum <code>jQuery.sap.log.Level</code> of log entries that will be recorded.
|
683 | * Log entries with a higher (less important) log level will be omitted from the log.
|
684 | * When a component name is given, the log level will be configured for that component
|
685 | * only, otherwise the log level for the default component of this logger is set.
|
686 | * For the global logger, the global default level is set.
|
687 | *
|
688 | * <b>Note</b>: Setting a global default log level has no impact on already defined
|
689 | * component log levels. They always override the global default log level.
|
690 | *
|
691 | * @param {jQuery.sap.log.Level} iLogLevel The new log level
|
692 | * @param {string} [sComponent] The log component to set the log level for
|
693 | * @return {jQuery.sap.log.Logger} This logger object to allow method chaining
|
694 | * @public
|
695 | * @name jQuery.sap.log.Logger#setLevel
|
696 | * @function
|
697 | */
|
698 |
|
699 | /**
|
700 | * Returns the log level currently effective for the given component.
|
701 | * If no component is given or when no level has been configured for a
|
702 | * given component, the log level for the default component of this logger is returned.
|
703 | *
|
704 | * @param {string} [sComponent] Name of the component to retrieve the log level for
|
705 | * @return {int} The log level for the given component or the default log level
|
706 | * @public
|
707 | * @since 1.1.2
|
708 | * @name jQuery.sap.log.Logger#getLevel
|
709 | * @function
|
710 | */
|
711 |
|
712 | /**
|
713 | * Checks whether logging is enabled for the given log level,
|
714 | * depending on the currently effective log level for the given component.
|
715 | *
|
716 | * If no component is given, the default component of this logger will be taken into account.
|
717 | *
|
718 | * @param {int} [iLevel=Level.DEBUG] The log level in question
|
719 | * @param {string} [sComponent] Name of the component to check the log level for
|
720 | * @return {boolean} Whether logging is enabled or not
|
721 | * @public
|
722 | * @since 1.13.2
|
723 | * @name jQuery.sap.log.Logger#isLoggable
|
724 | * @function
|
725 | */
|
726 |
|
727 | /**
|
728 | * A Logging API for JavaScript.
|
729 | *
|
730 | * Provides methods to manage a client-side log and to create entries in it. Each of the logging methods
|
731 | * {@link jQuery.sap.log.debug}, {@link jQuery.sap.log.info}, {@link jQuery.sap.log.warning},
|
732 | * {@link jQuery.sap.log.error} and {@link jQuery.sap.log.fatal} creates and records a log entry,
|
733 | * containing a timestamp, a log level, a message with details and a component info.
|
734 | * The log level will be one of {@link jQuery.sap.log.Level} and equals the name of the concrete logging method.
|
735 | *
|
736 | * By using the {@link jQuery.sap.log.setLevel} method, consumers can determine the least important
|
737 | * log level which should be recorded. Less important entries will be filtered out. (Note that higher numeric
|
738 | * values represent less important levels). The initially set level depends on the mode that UI5 is running in.
|
739 | * When the optimized sources are executed, the default level will be {@link jQuery.sap.log.Level.ERROR}.
|
740 | * For normal (debug sources), the default level is {@link jQuery.sap.log.Level.DEBUG}.
|
741 | *
|
742 | * All logging methods allow to specify a <b>component</b>. These components are simple strings and
|
743 | * don't have a special meaning to the UI5 framework. However they can be used to semantically group
|
744 | * log entries that belong to the same software component (or feature). There are two APIs that help
|
745 | * to manage logging for such a component. With <code>{@link jQuery.sap.log.getLogger}(sComponent)</code>,
|
746 | * one can retrieve a logger that automatically adds the given <code>sComponent</code> as component
|
747 | * parameter to each log entry, if no other component is specified. Typically, JavaScript code will
|
748 | * retrieve such a logger once during startup and reuse it for the rest of its lifecycle.
|
749 | * Second, the {@link jQuery.sap.log.Logger#setLevel}(iLevel, sComponent) method allows to set the log level
|
750 | * for a specific component only. This allows a more fine granular control about the created logging entries.
|
751 | * {@link jQuery.sap.log.Logger#getLevel} allows to retrieve the currently effective log level for a given
|
752 | * component.
|
753 | *
|
754 | * {@link jQuery.sap.log.getLogEntries} returns an array of the currently collected log entries.
|
755 | *
|
756 | * Furthermore, a listener can be registered to the log. It will be notified whenever a new entry
|
757 | * is added to the log. The listener can be used for displaying log entries in a separate page area,
|
758 | * or for sending it to some external target (server).
|
759 | *
|
760 | * @since 0.9.0
|
761 | * @namespace
|
762 | * @public
|
763 | * @borrows jQuery.sap.log.Logger#fatal as fatal
|
764 | * @borrows jQuery.sap.log.Logger#error as error
|
765 | * @borrows jQuery.sap.log.Logger#warning as warning
|
766 | * @borrows jQuery.sap.log.Logger#info as info
|
767 | * @borrows jQuery.sap.log.Logger#debug as debug
|
768 | * @borrows jQuery.sap.log.Logger#trace as trace
|
769 | * @borrows jQuery.sap.log.Logger#getLevel as getLevel
|
770 | * @borrows jQuery.sap.log.Logger#setLevel as setLevel
|
771 | * @borrows jQuery.sap.log.Logger#isLoggable as isLoggable
|
772 | * @deprecated since 1.58 use {@link module:sap/base/Log} instead
|
773 | */
|
774 | jQuery.sap.log = Object.assign(Log.getLogger(), /** @lends jQuery.sap.log */ {
|
775 |
|
776 | /**
|
777 | * Enumeration of the configurable log levels that a Logger should persist to the log.
|
778 | *
|
779 | * Only if the current LogLevel is higher than the level {@link jQuery.sap.log.Level} of the currently added log entry,
|
780 | * then this very entry is permanently added to the log. Otherwise it is ignored.
|
781 | * @see jQuery.sap.log.Logger#setLevel
|
782 | * @enum {int}
|
783 | * @public
|
784 | * @deprecated since 1.58 use {@link module:sap/base/Log.Level} instead
|
785 | */
|
786 | Level: Log.Level,
|
787 |
|
788 | /**
|
789 | * Do not log anything
|
790 | * @public
|
791 | * @name jQuery.sap.log.Level.NONE
|
792 | * @type {int}
|
793 | */
|
794 | /**
|
795 | * Fatal level. Use this for logging unrecoverable situations
|
796 | * @public
|
797 | * @name jQuery.sap.log.Level.FATAL
|
798 | * @type {int}
|
799 | */
|
800 | /**
|
801 | * Error level. Use this for logging of erroneous but still recoverable situations
|
802 | * @public
|
803 | * @name jQuery.sap.log.Level.ERROR
|
804 | * @type {int}
|
805 | */
|
806 | /**
|
807 | * Warning level. Use this for logging unwanted but foreseen situations
|
808 | * @public
|
809 | * @name jQuery.sap.log.Level.WARNING
|
810 | * @type {int}
|
811 | */
|
812 | /**
|
813 | * Info level. Use this for logging information of purely informative nature
|
814 | * @public
|
815 | * @name jQuery.sap.log.Level.INFO
|
816 | * @type {int}
|
817 | */
|
818 | /**
|
819 | * Debug level. Use this for logging information necessary for debugging
|
820 | * @public
|
821 | * @name jQuery.sap.log.Level.DEBUG
|
822 | * @type {int}
|
823 | */
|
824 | /**
|
825 | * Trace level. Use this for tracing the program flow.
|
826 | * @public
|
827 | * @name jQuery.sap.log.Level.TRACE
|
828 | * @type {int}
|
829 | */
|
830 | /**
|
831 | * Trace level to log everything.
|
832 | * @public
|
833 | * @name jQuery.sap.log.Level.ALL
|
834 | * @type {int}
|
835 | */
|
836 |
|
837 | /**
|
838 | * Returns a {@link jQuery.sap.log.Logger} for the given component.
|
839 | *
|
840 | * The method might or might not return the same logger object across multiple calls.
|
841 | * While loggers are assumed to be light weight objects, consumers should try to
|
842 | * avoid redundant calls and instead keep references to already retrieved loggers.
|
843 | *
|
844 | * The optional second parameter <code>iDefaultLogLevel</code> allows to specify
|
845 | * a default log level for the component. It is only applied when no log level has been
|
846 | * defined so far for that component (ignoring inherited log levels). If this method is
|
847 | * called multiple times for the same component but with different log levels,
|
848 | * only the first call one might be taken into account.
|
849 | *
|
850 | * @param {string} sComponent Component to create the logger for
|
851 | * @param {int} [iDefaultLogLevel] a default log level to be used for the component,
|
852 | * if no log level has been defined for it so far.
|
853 | * @return {jQuery.sap.log.Logger} A logger for the component.
|
854 | * @public
|
855 | * @static
|
856 | * @since 1.1.2
|
857 | * @function
|
858 | */
|
859 | getLogger: Log.getLogger,
|
860 |
|
861 | /**
|
862 | * Returns the logged entries recorded so far as an array.
|
863 | *
|
864 | * Log entries are plain JavaScript objects with the following properties
|
865 | * <ul>
|
866 | * <li>timestamp {number} point in time when the entry was created</li>
|
867 | * <li>level {int} LogLevel level of the entry</li>
|
868 | * <li>message {string} message text of the entry</li>
|
869 | * </ul>
|
870 | *
|
871 | * @return {object[]} an array containing the recorded log entries
|
872 | * @public
|
873 | * @static
|
874 | * @since 1.1.2
|
875 | * @function
|
876 | */
|
877 | getLogEntries: Log.getLogEntries,
|
878 |
|
879 | /**
|
880 | * Allows to add a new LogListener that will be notified for new log entries.
|
881 | *
|
882 | * The given object must provide method <code>onLogEntry</code> and can also be informed
|
883 | * about <code>onDetachFromLog</code> and <code>onAttachToLog</code>
|
884 | * @param {object} oListener The new listener object that should be informed
|
885 | * @return {jQuery.sap.log} The global logger
|
886 | * @public
|
887 | * @static
|
888 | * @function
|
889 | */
|
890 | addLogListener: Log.addLogListener,
|
891 |
|
892 | /**
|
893 | * Allows to remove a registered LogListener.
|
894 | * @param {object} oListener The new listener object that should be removed
|
895 | * @return {jQuery.sap.log} The global logger
|
896 | * @public
|
897 | * @static
|
898 | * @function
|
899 | */
|
900 | removeLogListener: Log.removeLogListener,
|
901 |
|
902 | /**
|
903 | * Enables or disables whether additional support information is logged in a trace.
|
904 | * If enabled, logging methods like error, warning, info and debug are calling the additional
|
905 | * optional callback parameter fnSupportInfo and store the returned object in the log entry property supportInfo.
|
906 | *
|
907 | * @param {boolean} bEnabled true if the support information should be logged
|
908 | * @private
|
909 | * @static
|
910 | * @since 1.46.0
|
911 | * @function
|
912 | */
|
913 | logSupportInfo: Log.logSupportInfo,
|
914 |
|
915 | /**
|
916 | * Enumeration of levels that can be used in a call to {@link jQuery.sap.log.Logger#setLevel}(iLevel, sComponent).
|
917 | *
|
918 | * @deprecated Since 1.1.2. To streamline the Logging API a bit, the separation between Level and LogLevel has been given up.
|
919 | * Use the (enriched) enumeration {@link jQuery.sap.log.Level} instead.
|
920 | * @enum
|
921 | * @public
|
922 | */
|
923 | LogLevel: Log.Level,
|
924 |
|
925 | /**
|
926 | * Retrieves the currently recorded log entries.
|
927 | * @deprecated Since 1.1.2. To avoid confusion with getLogger, this method has been renamed to {@link jQuery.sap.log.getLogEntries}.
|
928 | * @function
|
929 | * @public
|
930 | */
|
931 | getLog: Log.getLogEntries
|
932 |
|
933 | });
|
934 |
|
935 |
|
936 | var sWindowName = (typeof window === "undefined" || window.top == window) ? "" : "[" + window.location.pathname.split('/').slice(-1)[0] + "] ";
|
937 |
|
938 | /**
|
939 | * A simple assertion mechanism that logs a message when a given condition is not met.
|
940 | *
|
941 | * <b>Note:</b> Calls to this method might be removed when the JavaScript code
|
942 | * is optimized during build. Therefore, callers should not rely on any side effects
|
943 | * of this method.
|
944 | *
|
945 | * @param {boolean} bResult Result of the checked assertion
|
946 | * @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.
|
947 | *
|
948 | * @public
|
949 | * @static
|
950 | * @SecSink {1|SECRET} Could expose secret data in logs
|
951 | * @function
|
952 | * @deprecated since 1.58 use {@link module:sap/base/assert} instead
|
953 | */
|
954 | jQuery.sap.assert = function(bResult, vMessage) {
|
955 | if (!bResult) {
|
956 | var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
|
957 | assert(bResult, sWindowName + sMessage);
|
958 | }
|
959 | };
|
960 |
|
961 | // evaluate configuration
|
962 | oCfgData.loglevel = (function() {
|
963 | var m = /(?:\?|&)sap-ui-log(?:L|-l)evel=([^&]*)/.exec(window.location.search);
|
964 | return m && m[1];
|
965 | }()) || oCfgData.loglevel;
|
966 | if ( oCfgData.loglevel ) {
|
967 | Log.setLevel(Log.Level[oCfgData.loglevel.toUpperCase()] || parseInt(oCfgData.loglevel));
|
968 | } else if (!window["sap-ui-optimized"]) {
|
969 | Log.setLevel(Log.Level.DEBUG);
|
970 | }
|
971 |
|
972 | Log.info("SAP Logger started.");
|
973 | // log early logs
|
974 | jQuery.each(_earlyLogs, function(i,e) {
|
975 | Log[e.level](e.message);
|
976 | });
|
977 | _earlyLogs = null;
|
978 |
|
979 | // ------------------------------------------- OBJECT --------------------------------------------------------
|
980 |
|
981 | /**
|
982 | * Returns a new constructor function that creates objects with
|
983 | * the given prototype.
|
984 | *
|
985 | * As of 1.45.0, this method has been deprecated. Use the following code pattern instead:
|
986 | * <pre>
|
987 | * function MyFunction() {
|
988 | * };
|
989 | * MyFunction.prototype = oPrototype;
|
990 | * </pre>
|
991 | * @param {object} oPrototype Prototype to use for the new objects
|
992 | * @return {function} the newly created constructor function
|
993 | * @public
|
994 | * @static
|
995 | * @deprecated As of 1.45.0, define your own function and assign <code>oPrototype</code> to its <code>prototype</code> property instead.
|
996 | */
|
997 | jQuery.sap.factory = function factory(oPrototype) {
|
998 | jQuery.sap.assert(typeof oPrototype == "object", "oPrototype must be an object (incl. null)");
|
999 | function Factory() {}
|
1000 | Factory.prototype = oPrototype;
|
1001 | return Factory;
|
1002 | };
|
1003 |
|
1004 | /**
|
1005 | * Returns a new object which has the given <code>oPrototype</code> as its prototype.
|
1006 | *
|
1007 | * If several objects with the same prototype are to be created,
|
1008 | * {@link jQuery.sap.factory} should be used instead.
|
1009 | *
|
1010 | * @param {object} oPrototype Prototype to use for the new object
|
1011 | * @return {object} new object
|
1012 | * @public
|
1013 | * @static
|
1014 | * @deprecated As of 1.45.0, use <code>Object.create(oPrototype)</code> instead.
|
1015 | */
|
1016 | jQuery.sap.newObject = function newObject(oPrototype) {
|
1017 | jQuery.sap.assert(typeof oPrototype == "object", "oPrototype must be an object (incl. null)");
|
1018 | // explicitly fall back to null for best compatibility with old implementation
|
1019 | return Object.create(oPrototype || null);
|
1020 | };
|
1021 |
|
1022 | /**
|
1023 | * Returns a new function that returns the given <code>oValue</code> (using its closure).
|
1024 | *
|
1025 | * Avoids the need for a dedicated member for the value.
|
1026 | *
|
1027 | * As closures don't come for free, this function should only be used when polluting
|
1028 | * the enclosing object is an absolute "must-not" (as it is the case in public base classes).
|
1029 | *
|
1030 | * @param {object} oValue The value that the getter should return
|
1031 | * @returns {function} The new getter function
|
1032 | * @public
|
1033 | * @static
|
1034 | * @function
|
1035 | * @deprecated since 1.58
|
1036 | */
|
1037 | jQuery.sap.getter = function(oValue) {
|
1038 | return function() {
|
1039 | return oValue;
|
1040 | };
|
1041 | };
|
1042 |
|
1043 | /**
|
1044 | * Returns a JavaScript object which is identified by a sequence of names.
|
1045 | *
|
1046 | * A call to <code>getObject("a.b.C")</code> has essentially the same effect
|
1047 | * as accessing <code>window.a.b.C</code> but with the difference that missing
|
1048 | * intermediate objects (a or b in the example above) don't lead to an exception.
|
1049 | *
|
1050 | * When the addressed object exists, it is simply returned. If it doesn't exists,
|
1051 | * the behavior depends on the value of the second, optional parameter
|
1052 | * <code>iNoCreates</code> (assuming 'n' to be the number of names in the name sequence):
|
1053 | * <ul>
|
1054 | * <li>NaN: if iNoCreates is not a number and the addressed object doesn't exist,
|
1055 | * then <code>getObject()</code> returns <code>undefined</code>.
|
1056 | * <li>0 < iNoCreates < n: any non-existing intermediate object is created, except
|
1057 | * the <i>last</i> <code>iNoCreates</code> ones.
|
1058 | * </ul>
|
1059 | *
|
1060 | * Example:
|
1061 | * <pre>
|
1062 | * getObject() -- returns the context object (either param or window)
|
1063 | * getObject("a.b.C") -- will only try to get a.b.C and return undefined if not found.
|
1064 | * getObject("a.b.C", 0) -- will create a, b, and C in that order if they don't exists
|
1065 | * getObject("a.b.c", 1) -- will create a and b, but not C.
|
1066 | * </pre>
|
1067 | *
|
1068 | * When a <code>oContext</code> is given, the search starts in that object.
|
1069 | * Otherwise it starts in the <code>window</code> object that this plugin
|
1070 | * has been created in.
|
1071 | *
|
1072 | * Note: Although this method internally uses <code>object["key"]</code> to address object
|
1073 | * properties, it does not support all possible characters in a name.
|
1074 | * Especially the dot ('.') is not supported in the individual name segments,
|
1075 | * as it is always interpreted as a name separator.
|
1076 | *
|
1077 | * @param {string} sName a dot separated sequence of names that identify the required object
|
1078 | * @param {int} [iNoCreates=NaN] number of objects (from the right) that should not be created
|
1079 | * @param {object} [oContext=window] the context to execute the search in
|
1080 | * @returns {function} The value of the named object
|
1081 | *
|
1082 | * @public
|
1083 | * @static
|
1084 | * @deprecated since 1.58 use {@link module:sap/base/util/ObjectPath.get} or
|
1085 | * {@link module:sap/base/util/ObjectPath.set} instead
|
1086 | */
|
1087 | jQuery.sap.getObject = function(sName, iNoCreates, oContext) {
|
1088 | var oObject = oContext || window,
|
1089 | aNames = (sName || "").split("."),
|
1090 | l = aNames.length,
|
1091 | iEndCreate = isNaN(iNoCreates) ? 0 : l - iNoCreates,
|
1092 | i;
|
1093 |
|
1094 | if ( syncCallBehavior && oContext === window ) {
|
1095 | Log.error("[nosync] getObject called to retrieve global name '" + sName + "'");
|
1096 | }
|
1097 |
|
1098 | for (i = 0; oObject && i < l; i++) {
|
1099 | if (!oObject[aNames[i]] && i < iEndCreate ) {
|
1100 | oObject[aNames[i]] = {};
|
1101 | }
|
1102 | oObject = oObject[aNames[i]];
|
1103 | }
|
1104 | return oObject;
|
1105 | };
|
1106 |
|
1107 | /**
|
1108 | * Sets an object property to a given value, where the property is
|
1109 | * identified by a sequence of names (path).
|
1110 | *
|
1111 | * When a <code>oContext</code> is given, the path starts in that object.
|
1112 | * Otherwise it starts in the <code>window</code> object that this plugin
|
1113 | * has been created for.
|
1114 | *
|
1115 | * Note: Although this method internally uses <code>object["key"]</code> to address object
|
1116 | * properties, it does not support all possible characters in a name.
|
1117 | * Especially the dot ('.') is not supported in the individual name segments,
|
1118 | * as it is always interpreted as a name separator.
|
1119 | *
|
1120 | * @param {string} sName a dot separated sequence of names that identify the property
|
1121 | * @param {any} vValue value to be set, can have any type
|
1122 | * @param {object} [oContext=window] the context to execute the search in
|
1123 | * @public
|
1124 | * @static
|
1125 | * @deprecated since 1.58 use {@link module:sap/base/util/ObjectPath.set} instead
|
1126 | */
|
1127 | jQuery.sap.setObject = function (sName, vValue, oContext) {
|
1128 | var oObject = oContext || window,
|
1129 | aNames = (sName || "").split("."),
|
1130 | l = aNames.length, i;
|
1131 |
|
1132 | if ( l > 0 ) {
|
1133 | for (i = 0; oObject && i < l - 1; i++) {
|
1134 | if (!oObject[aNames[i]] ) {
|
1135 | oObject[aNames[i]] = {};
|
1136 | }
|
1137 | oObject = oObject[aNames[i]];
|
1138 | }
|
1139 | oObject[aNames[l - 1]] = vValue;
|
1140 | }
|
1141 | };
|
1142 |
|
1143 | // ---------------------- performance measurement -----------------------------------------------------------
|
1144 |
|
1145 | /**
|
1146 | * Namespace for the jQuery performance measurement plug-in provided by SAP SE.
|
1147 | *
|
1148 | * @name jQuery.sap.measure
|
1149 | * @namespace
|
1150 | * @public
|
1151 | * @static
|
1152 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement} or {@link module:sap/ui/performance/trace/Interaction} instead
|
1153 | */
|
1154 | jQuery.sap.measure = Measurement;
|
1155 |
|
1156 | /**
|
1157 | * Gets the current state of the performance measurement functionality
|
1158 | *
|
1159 | * @name jQuery.sap.measure.getActive
|
1160 | * @function
|
1161 | * @return {boolean} current state of the performance measurement functionality
|
1162 | * @public
|
1163 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getActive} instead
|
1164 | */
|
1165 |
|
1166 | /**
|
1167 | * Activates or deactivates the performance measure functionality
|
1168 | * Optionally a category or list of categories can be passed to restrict measurements to certain categories
|
1169 | * like "javascript", "require", "xmlhttprequest", "render"
|
1170 | * @param {boolean} bOn - state of the performance measurement functionality to set
|
1171 | * @param {string | string[]} aCategories - An optional list of categories that should be measured
|
1172 | *
|
1173 | * @return {boolean} current state of the performance measurement functionality
|
1174 | * @name jQuery.sap.measure#setActive
|
1175 | * @function
|
1176 | * @public
|
1177 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.setActive} instead
|
1178 | */
|
1179 |
|
1180 | /**
|
1181 | * Starts a performance measure.
|
1182 | * Optionally a category or list of categories can be passed to allow filtering of measurements.
|
1183 | *
|
1184 | * @name jQuery.sap.measure.start
|
1185 | * @function
|
1186 | * @param {string} sId ID of the measurement
|
1187 | * @param {string} sInfo Info for the measurement
|
1188 | * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure
|
1189 | *
|
1190 | * @return {object} current measurement containing id, info and start-timestamp (false if error)
|
1191 | * @public
|
1192 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.start} instead
|
1193 | */
|
1194 |
|
1195 | /**
|
1196 | * Pauses a performance measure
|
1197 | *
|
1198 | * @name jQuery.sap.measure.pause
|
1199 | * @function
|
1200 | * @param {string} sId ID of the measurement
|
1201 | * @return {object} current measurement containing id, info and start-timestamp, pause-timestamp (false if error)
|
1202 | * @public
|
1203 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.pause} instead
|
1204 | */
|
1205 |
|
1206 | /**
|
1207 | * Resumes a performance measure
|
1208 | *
|
1209 | * @name jQuery.sap.measure.resume
|
1210 | * @function
|
1211 | * @param {string} sId ID of the measurement
|
1212 | * @return {object} current measurement containing id, info and start-timestamp, resume-timestamp (false if error)
|
1213 | * @public
|
1214 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.resume} instead
|
1215 | */
|
1216 |
|
1217 | /**
|
1218 | * Ends a performance measure
|
1219 | *
|
1220 | * @name jQuery.sap.measure.end
|
1221 | * @function
|
1222 | * @param {string} sId ID of the measurement
|
1223 | * @return {object} current measurement containing id, info and start-timestamp, end-timestamp, time, duration (false if error)
|
1224 | * @public
|
1225 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.end} instead
|
1226 | */
|
1227 |
|
1228 | /**
|
1229 | * Clears all performance measurements
|
1230 | *
|
1231 | * @name jQuery.sap.measure.clear
|
1232 | * @function
|
1233 | * @public
|
1234 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.clear} instead
|
1235 | */
|
1236 |
|
1237 | /**
|
1238 | * Removes a performance measure
|
1239 | *
|
1240 | * @name jQuery.sap.measure.remove
|
1241 | * @function
|
1242 | * @param {string} sId ID of the measurement
|
1243 | * @public
|
1244 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.remove} instead
|
1245 | */
|
1246 |
|
1247 | /**
|
1248 | * Adds a performance measurement with all data
|
1249 | * This is useful to add external measurements (e.g. from a backend) to the common measurement UI
|
1250 | *
|
1251 | * @name jQuery.sap.measure.add
|
1252 | * @function
|
1253 | * @param {string} sId ID of the measurement
|
1254 | * @param {string} sInfo Info for the measurement
|
1255 | * @param {int} iStart start timestamp
|
1256 | * @param {int} iEnd end timestamp
|
1257 | * @param {int} iTime time in milliseconds
|
1258 | * @param {int} iDuration effective time in milliseconds
|
1259 | * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure
|
1260 | * @return {object} [] current measurement containing id, info and start-timestamp, end-timestamp, time, duration, categories (false if error)
|
1261 | * @public
|
1262 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.add} instead
|
1263 | */
|
1264 |
|
1265 | /**
|
1266 | * Starts an average performance measure.
|
1267 | * The duration of this measure is an avarage of durations measured for each call.
|
1268 | * Optionally a category or list of categories can be passed to allow filtering of measurements.
|
1269 | *
|
1270 | * @name jQuery.sap.measure.average
|
1271 | * @function
|
1272 | * @param {string} sId ID of the measurement
|
1273 | * @param {string} sInfo Info for the measurement
|
1274 | * @param {string | string[]} [aCategories = "javascript"] An optional list of categories for the measure
|
1275 | * @return {object} current measurement containing id, info and start-timestamp (false if error)
|
1276 | * @public
|
1277 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.average} instead
|
1278 | */
|
1279 |
|
1280 | /**
|
1281 | * Gets a performance measure
|
1282 | *
|
1283 | * @name jQuery.sap.measure.getMeasurement
|
1284 | * @function
|
1285 | * @param {string} sId ID of the measurement
|
1286 | * @return {object} current measurement containing id, info and start-timestamp, end-timestamp, time, duration (false if error)
|
1287 | * @public
|
1288 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getMeasurement} instead
|
1289 | */
|
1290 |
|
1291 | /**
|
1292 | * Gets all performance measurements
|
1293 | *
|
1294 | * @name jQuery.sap.measure.getAllMeasurements
|
1295 | * @function
|
1296 | * @param {boolean} [bCompleted] Whether only completed measurements should be returned, if explicitly set to false only incomplete measurements are returned
|
1297 | * @return {object[]} current array with measurements containing id, info and start-timestamp, end-timestamp, time, duration, categories
|
1298 | * @public
|
1299 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.getAllMeasurements} instead
|
1300 | */
|
1301 |
|
1302 | /**
|
1303 | * Gets all performance measurements where a provided filter function returns a truthy value.
|
1304 | * If neither a filter function nor a category is provided an empty array is returned.
|
1305 | * To filter for certain properties of measurements a fnFilter can be implemented like this
|
1306 | * <code>
|
1307 | * function(oMeasurement) {
|
1308 | * return oMeasurement.duration > 50;
|
1309 | * }</code>
|
1310 | *
|
1311 | * @name jQuery.sap.measure.filterMeasurements
|
1312 | * @function
|
1313 | * @param {function} [fnFilter] a filter function that returns true if the passed measurement should be added to the result
|
1314 | * @param {boolean|undefined} [bCompleted] Optional parameter to determine if either completed or incomplete measurements should be returned (both if not set or undefined)
|
1315 | * @param {string[]} [aCategories] The function returns only measurements which match these specified categories
|
1316 | *
|
1317 | * @return {object} [] filtered array with measurements containing id, info and start-timestamp, end-timestamp, time, duration, categories (false if error)
|
1318 | * @public
|
1319 | * @since 1.34.0
|
1320 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.filterMeasurements} instead
|
1321 | */
|
1322 |
|
1323 | /**
|
1324 | * Registers an average measurement for a given objects method
|
1325 | *
|
1326 | * @name jQuery.sap.measure.registerMethod
|
1327 | * @function
|
1328 | * @param {string} sId the id of the measurement
|
1329 | * @param {object} oObject the object of the method
|
1330 | * @param {string} sMethod the name of the method
|
1331 | * @param {string[]} [aCategories = ["javascript"]] An optional categories list for the measurement
|
1332 | *
|
1333 | * @returns {boolean} true if the registration was successful
|
1334 | * @public
|
1335 | * @since 1.34.0
|
1336 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.registerMethod} instead
|
1337 | */
|
1338 |
|
1339 | /**
|
1340 | * Unregisters an average measurement for a given objects method
|
1341 | *
|
1342 | * @name jQuery.sap.measure.unregisterMethod
|
1343 | * @function
|
1344 | * @param {string} sId the id of the measurement
|
1345 | * @param {object} oObject the object of the method
|
1346 | * @param {string} sMethod the name of the method
|
1347 | *
|
1348 | * @returns {boolean} true if the unregistration was successful
|
1349 | * @public
|
1350 | * @since 1.34.0
|
1351 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.unregisterMethod} instead
|
1352 | */
|
1353 |
|
1354 | /**
|
1355 | * Unregisters all average measurements
|
1356 | *
|
1357 | * @name jQuery.sap.measure.unregisterAllMethods
|
1358 | * @function
|
1359 | * @public
|
1360 | * @since 1.34.0
|
1361 | * @deprecated since 1.58 use {@link module:sap/ui/performance/Measurement.unregisterAllMethods} instead
|
1362 | */
|
1363 |
|
1364 | /**
|
1365 | * Clears all interaction measurements
|
1366 | *
|
1367 | * @function
|
1368 | * @public
|
1369 | * @since 1.34.0
|
1370 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.clear} instead
|
1371 | */
|
1372 | jQuery.sap.measure.clearInteractionMeasurements = Interaction.clear;
|
1373 |
|
1374 | /**
|
1375 | * Start an interaction measurements
|
1376 | *
|
1377 | * @function
|
1378 | * @param {string} sType type of the event which triggered the interaction
|
1379 | * @param {object} oSrcElement the control on which the interaction was triggered
|
1380 | * @public
|
1381 | * @since 1.34.0
|
1382 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.start} instead
|
1383 | */
|
1384 | jQuery.sap.measure.startInteraction = Interaction.start;
|
1385 |
|
1386 | /**
|
1387 | * End an interaction measurements
|
1388 | *
|
1389 | * @function
|
1390 | * @param {boolean} bForce forces end of interaction now and ignores further re-renderings
|
1391 | * @public
|
1392 | * @since 1.34.0
|
1393 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.end} instead
|
1394 | */
|
1395 | jQuery.sap.measure.endInteraction = Interaction.end;
|
1396 |
|
1397 | /**
|
1398 | * Gets the incomplete pending interaction
|
1399 | * @function
|
1400 | * @return {object} interaction measurement
|
1401 | * @private
|
1402 | * @since 1.34.0
|
1403 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.getPending} instead
|
1404 | */
|
1405 | jQuery.sap.measure.getPendingInteractionMeasurement = Interaction.getPending;
|
1406 |
|
1407 | /**
|
1408 | * Gets all interaction measurements for which a provided filter function returns a truthy value.
|
1409 | * To filter for certain categories of measurements a fnFilter can be implemented like this
|
1410 | * <code>
|
1411 | * function(InteractionMeasurement) {
|
1412 | * return InteractionMeasurement.duration > 0
|
1413 | * }</code>
|
1414 | *
|
1415 | * @function
|
1416 | * @param {function} fnFilter a filter function that returns true if the passed measurement should be added to the result
|
1417 | * @return {object[]} all interaction measurements passing the filter function successfully
|
1418 | * @public
|
1419 | * @since 1.36.2
|
1420 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.filter} instead
|
1421 | */
|
1422 | jQuery.sap.measure.filterInteractionMeasurements = Interaction.filter;
|
1423 |
|
1424 | /**
|
1425 | * Gets all interaction measurements
|
1426 | * @function
|
1427 | * @param {boolean} bFinalize finalize the current pending interaction so that it is contained in the returned array
|
1428 | * @return {object[]} all interaction measurements
|
1429 | * @public
|
1430 | * @since 1.34.0
|
1431 | * @deprecated since 1.58 use {@link module:sap/ui/performance/trace/Interaction.getAll} instead
|
1432 | */
|
1433 | jQuery.sap.measure.getAllInteractionMeasurements = Interaction.getAll;
|
1434 |
|
1435 | /**
|
1436 | * Gets the current request timings array for type 'resource' safely
|
1437 | *
|
1438 | * @function
|
1439 | * @return {object[]} array of performance timing objects
|
1440 | * @public
|
1441 | * @since 1.34.0
|
1442 | * @deprecated since 1.58 use native function <code>performance.getEntriesByType("resource")</code> instead
|
1443 | */
|
1444 | jQuery.sap.measure.getRequestTimings = function() {
|
1445 | if (window.performance.getEntriesByType) {
|
1446 | return window.performance.getEntriesByType("resource");
|
1447 | }
|
1448 | return [];
|
1449 | };
|
1450 |
|
1451 | /**
|
1452 | * Clears all request timings safely.
|
1453 | *
|
1454 | * @function
|
1455 | * @public
|
1456 | * @since 1.34.0
|
1457 | * @deprecated since 1.58 use native function <code>performance.clearResourceTimings()</code> where available
|
1458 | */
|
1459 | jQuery.sap.measure.clearRequestTimings = function() {
|
1460 | if (window.performance.clearResourceTimings) {
|
1461 | window.performance.clearResourceTimings();
|
1462 | }
|
1463 | };
|
1464 |
|
1465 |
|
1466 | /**
|
1467 | * Sets the request buffer size for the measurement safely.
|
1468 | *
|
1469 | * @param {int} iSize size of the buffer
|
1470 | * @function
|
1471 | * @public
|
1472 | * @since 1.34.0
|
1473 | * @deprecated since 1.58 use native function <code>performance.setResourceTimingBufferSize(iSize)</code> where available
|
1474 | */
|
1475 | jQuery.sap.measure.setRequestBufferSize = function(iSize) {
|
1476 | if (window.performance.setResourceTimingBufferSize) {
|
1477 | window.performance.setResourceTimingBufferSize(iSize);
|
1478 | }
|
1479 | };
|
1480 |
|
1481 | // ---------------------- require/declare --------------------------------------------------------
|
1482 |
|
1483 | var getModuleSystemInfo = (function() {
|
1484 |
|
1485 | /**
|
1486 | * Local logger for messages related to module loading.
|
1487 | *
|
1488 | * By default, the log level is the same as for the standard log, but not higher than <code>INFO</code>.
|
1489 | * With the experimental config option <code>xx-debugModuleLoading</code>, it can be raised to <code>DEBUG</code>.
|
1490 | * @private
|
1491 | */
|
1492 | var oLog = _ui5loader.logger = Log.getLogger("sap.ui.ModuleSystem",
|
1493 | (/sap-ui-xx-debug(M|-m)odule(L|-l)oading=(true|x|X)/.test(location.search) || oCfgData["xx-debugModuleLoading"]) ? Log.Level.DEBUG : Math.min(Log.getLevel(), Log.Level.INFO)
|
1494 | ),
|
1495 |
|
1496 | mKnownSubtypes = LoaderExtensions.getKnownSubtypes(),
|
1497 |
|
1498 | rSubTypes;
|
1499 |
|
1500 | (function() {
|
1501 | var sSub = "";
|
1502 |
|
1503 | for (var sType in mKnownSubtypes) {
|
1504 | sSub = (sSub ? sSub + "|" : "") + "(?:(?:" + mKnownSubtypes[sType].join("\\.|") + "\\.)?" + sType + ")";
|
1505 | }
|
1506 | sSub = "\\.(?:" + sSub + "|[^./]+)$";
|
1507 | oLog.debug("constructed regexp for file sub-types :" + sSub);
|
1508 | rSubTypes = new RegExp(sSub);
|
1509 | }());
|
1510 |
|
1511 | function ui5ToRJS(sName) {
|
1512 | if ( /^jquery\.sap\./.test(sName) ) {
|
1513 | return sName;
|
1514 | }
|
1515 | return sName.replace(/\./g, "/");
|
1516 | }
|
1517 |
|
1518 | /**
|
1519 | * Constructs a URL to load the module with the given name and file type (suffix).
|
1520 | *
|
1521 | * Searches the longest prefix of the given module name for which a registration
|
1522 | * exists (see {@link jQuery.sap.registerModulePath}) and replaces that prefix
|
1523 | * by the registered URL prefix.
|
1524 | *
|
1525 | * The remainder of the module name is appended to the URL, replacing any dot with a slash.
|
1526 | *
|
1527 | * Finally, the given suffix (typically a file name extension) is added (unconverted).
|
1528 | *
|
1529 | * The returned name (without the suffix) doesn't end with a slash.
|
1530 | *
|
1531 | * @param {string} sModuleName module name to detemrine the path for
|
1532 | * @param {string} sSuffix suffix to be added to the resulting path
|
1533 | * @return {string} calculated path (URL) to the given module
|
1534 | *
|
1535 | * @public
|
1536 | * @static
|
1537 | * @deprecated since 1.58 use {@link sap.ui.require.toUrl} instead
|
1538 | */
|
1539 | jQuery.sap.getModulePath = function(sModuleName, sSuffix) {
|
1540 | return jQuery.sap.getResourcePath(ui5ToRJS(sModuleName), sSuffix);
|
1541 | };
|
1542 |
|
1543 | /**
|
1544 | * Determines the URL for a resource given its unified resource name.
|
1545 | *
|
1546 | * Searches the longest prefix of the given resource name for which a registration
|
1547 | * exists (see {@link jQuery.sap.registerResourcePath}) and replaces that prefix
|
1548 | * by the registered URL prefix.
|
1549 | *
|
1550 | * The remainder of the resource name is appended to the URL.
|
1551 | *
|
1552 | * <b>Unified Resource Names</b><br>
|
1553 | * Several UI5 APIs use <i>Unified Resource Names (URNs)</i> as naming scheme for resources that
|
1554 | * they deal with (e.h. Javascript, CSS, JSON, XML, ...). URNs are similar to the path
|
1555 | * component of a URL:
|
1556 | * <ul>
|
1557 | * <li>they consist of a non-empty sequence of name segments</li>
|
1558 | * <li>segments are separated by a forward slash '/'</li>
|
1559 | * <li>name segments consist of URL path segment characters only. It is recommended to use only ASCII
|
1560 | * letters (upper or lower case), digits and the special characters '$', '_', '-', '.')</li>
|
1561 | * <li>the empty name segment is not supported</li>
|
1562 | * <li>names consisting of dots only, are reserved and must not be used for resources</li>
|
1563 | * <li>names are case sensitive although the underlying server might be case-insensitive</li>
|
1564 | * <li>the behavior with regard to URL encoded characters is not specified, %ddd notation should be avoided</li>
|
1565 | * <li>the meaning of a leading slash is undefined, but might be defined in future. It therefore should be avoided</li>
|
1566 | * </ul>
|
1567 | *
|
1568 | * UI5 APIs that only deal with Javascript resources, use a slight variation of this scheme,
|
1569 | * where the extension '.js' is always omitted (see {@link sap.ui.define}, {@link sap.ui.require}).
|
1570 | *
|
1571 | *
|
1572 | * <b>Relationship to old Module Name Syntax</b><br>
|
1573 | *
|
1574 | * Older UI5 APIs that deal with resources (like {@link jQuery.sap.registerModulePath},
|
1575 | * {@link jQuery.sap.require} and {@link jQuery.sap.declare}) used a dot-separated naming scheme
|
1576 | * (called 'module names') which was motivated by object names in the global namespace in
|
1577 | * Javascript.
|
1578 | *
|
1579 | * The new URN scheme better matches the names of the corresponding resources (files) as stored
|
1580 | * in a server and the dot ('.') is no longer a forbidden character in a resource name. This finally
|
1581 | * allows to handle resources with different types (extensions) with the same API, not only JS files.
|
1582 | *
|
1583 | * Last but not least does the URN scheme better match the naming conventions used by AMD loaders
|
1584 | * (like <code>requireJS</code>).
|
1585 | *
|
1586 | * @param {string} sResourceName unified resource name of the resource
|
1587 | * @returns {string} URL to load the resource from
|
1588 | * @public
|
1589 | * @deprecated since 1.58 use {@link sap.ui.require.toUrl} instead
|
1590 | */
|
1591 | jQuery.sap.getResourcePath = function(sResourceName, sSuffix) {
|
1592 | // if no suffix was given and if the name is not empty, try to guess the suffix from the last segment
|
1593 | if ( arguments.length === 1 && sResourceName != '' ) {
|
1594 | // @evo-todo re-implement without split
|
1595 | // only known types (and their known subtypes) are accepted
|
1596 | var aSegments = sResourceName.split(/\//);
|
1597 | var m = rSubTypes.exec(aSegments[aSegments.length - 1]);
|
1598 | if ( m ) {
|
1599 | sSuffix = m[0];
|
1600 | aSegments[aSegments.length - 1] = aSegments[aSegments.length - 1].slice(0, m.index);
|
1601 | sResourceName = aSegments.join('/');
|
1602 | } else {
|
1603 | sSuffix = "";
|
1604 | }
|
1605 | }
|
1606 |
|
1607 | return _ui5loader.getResourcePath(sResourceName, sSuffix);
|
1608 | };
|
1609 |
|
1610 | /**
|
1611 | * Registers a URL prefix for a module name prefix.
|
1612 | *
|
1613 | * Before a module is loaded, the longest registered prefix of its module name
|
1614 | * is searched for and the associated URL prefix is used as a prefix for the request URL.
|
1615 | * The remainder of the module name is attached to the request URL by replacing
|
1616 | * dots ('.') with slashes ('/').
|
1617 | *
|
1618 | * The registration and search operates on full name segments only. So when a prefix
|
1619 | *
|
1620 | * 'sap.com' -> 'http://www.sap.com/ui5/resources/'
|
1621 | *
|
1622 | * is registered, then it will match the name
|
1623 | *
|
1624 | * 'sap.com.Button'
|
1625 | *
|
1626 | * but not
|
1627 | *
|
1628 | * 'sap.commons.Button'
|
1629 | *
|
1630 | * Note that the empty prefix ('') will always match and thus serves as a fallback for
|
1631 | * any search.
|
1632 | *
|
1633 | * The prefix can either be given as string or as object which contains the url and a 'final' property.
|
1634 | * If 'final' is set to true, overwriting a module prefix is not possible anymore.
|
1635 | *
|
1636 | * @param {string} sModuleName module name to register a path for
|
1637 | * @param {string | object} vUrlPrefix path prefix to register, either a string literal or an object (e.g. {url : 'url/to/res', 'final': true})
|
1638 | * @param {string} [vUrlPrefix.url] path prefix to register
|
1639 | * @param {boolean} [vUrlPrefix.final] flag to avoid overwriting the url path prefix for the given module name at a later point of time
|
1640 | *
|
1641 | * @public
|
1642 | * @static
|
1643 | * @deprecated since 1.58 set path mappings via {@link sap.ui.loader.config} instead.
|
1644 | * @SecSink {1|PATH} Parameter is used for future HTTP requests
|
1645 | */
|
1646 | jQuery.sap.registerModulePath = function registerModulePath(sModuleName, vUrlPrefix) {
|
1647 | jQuery.sap.assert(!/\//.test(sModuleName), "module name must not contain a slash.");
|
1648 | sModuleName = sModuleName.replace(/\./g, "/");
|
1649 | // URL must not be empty
|
1650 | vUrlPrefix = vUrlPrefix || '.';
|
1651 | LoaderExtensions.registerResourcePath(sModuleName, vUrlPrefix);
|
1652 | };
|
1653 |
|
1654 | /**
|
1655 | * Registers a URL prefix for a resource name prefix.
|
1656 | *
|
1657 | * Before a resource is loaded, the longest registered prefix of its unified resource name
|
1658 | * is searched for and the associated URL prefix is used as a prefix for the request URL.
|
1659 | * The remainder of the resource name is attached to the request URL 1:1.
|
1660 | *
|
1661 | * The registration and search operates on full name segments only. So when a prefix
|
1662 | *
|
1663 | * 'sap/com' -> 'http://www.sap.com/ui5/resources/'
|
1664 | *
|
1665 | * is registered, then it will match the name
|
1666 | *
|
1667 | * 'sap/com/Button'
|
1668 | *
|
1669 | * but not
|
1670 | *
|
1671 | * 'sap/commons/Button'
|
1672 | *
|
1673 | * Note that the empty prefix ('') will always match and thus serves as a fallback for
|
1674 | * any search.
|
1675 | *
|
1676 | * The url prefix can either be given as string or as object which contains the url and a final flag.
|
1677 | * If final is set to true, overwriting a resource name prefix is not possible anymore.
|
1678 | *
|
1679 | * @param {string} sResourceNamePrefix in unified resource name syntax
|
1680 | * @param {string | object} vUrlPrefix prefix to use instead of the sResourceNamePrefix, either a string literal or an object (e.g. {url : 'url/to/res', 'final': true})
|
1681 | * @param {string} [vUrlPrefix.url] path prefix to register
|
1682 | * @param {boolean} [vUrlPrefix.final] flag to avoid overwriting the url path prefix for the given module name at a later point of time
|
1683 | *
|
1684 | * @public
|
1685 | * @static
|
1686 | * @deprecated since 1.58 set path mappings via {@link sap.ui.loader.config} instead.
|
1687 | * @SecSink {1|PATH} Parameter is used for future HTTP requests
|
1688 | */
|
1689 | jQuery.sap.registerResourcePath = LoaderExtensions.registerResourcePath;
|
1690 |
|
1691 | /**
|
1692 | * Register information about third party modules that are not UI5 modules.
|
1693 | *
|
1694 | * The information maps the name of the module (without extension '.js') to an info object.
|
1695 | * Instead of a complete info object, only the value of the <code>deps</code> property can be given as an array.
|
1696 | *
|
1697 | * @param {object} mShims Map of shim configuration objects keyed by module names (withou extension '.js')
|
1698 | * @param {boolean} [mShims.any-module-name.amd=false]
|
1699 | * Whether the module uses an AMD loader if present. If set to <code>true</code>, UI5 will disable
|
1700 | * the AMD loader while loading such modules to force the modules to expose their content via global names.
|
1701 | * @param {string[]|string} [mShims.any-module-name.exports=undefined]
|
1702 | * Global name (or names) that are exported by the module. If one ore multiple names are defined,
|
1703 | * the first one will be read from the global object and will be used as value of the module.
|
1704 | * Each name can be a dot separated hierarchical name (will be resolved with <code>jQuery.sap.getObject</code>)
|
1705 | * @param {string[]} [mShims.any-module-name.deps=undefined]
|
1706 | * List of modules that the module depends on (requireJS syntax, no '.js').
|
1707 | * The modules will be loaded first before loading the module itself.
|
1708 | *
|
1709 | * @private
|
1710 | * @ui5-restricted sap.ui.core, sap.ui.export, sap.ui.vk
|
1711 | * @deprecated Since 1.58, use {@link sap.ui.loader.config} instead
|
1712 | */
|
1713 | jQuery.sap.registerModuleShims = function(mShims) {
|
1714 | jQuery.sap.assert( typeof mShims === 'object', "mShims must be an object");
|
1715 | ui5loader.config({
|
1716 | shim: mShims
|
1717 | });
|
1718 | };
|
1719 |
|
1720 | /**
|
1721 | * Check whether a given module has been loaded / declared already.
|
1722 | *
|
1723 | * Returns true as soon as a module has been required the first time, even when
|
1724 | * loading/executing it has not finished yet. So the main assertion of a
|
1725 | * return value of <code>true</code> is that the necessary actions have been taken
|
1726 | * to make the module available in the near future. It does not mean, that
|
1727 | * the content of the module is already available!
|
1728 | *
|
1729 | * This fuzzy behavior is necessary to avoid multiple requests for the same module.
|
1730 | * As a consequence of the assertion above, a <i>preloaded</i> module does not
|
1731 | * count as <i>declared</i>. For preloaded modules, an explicit call to
|
1732 | * <code>jQuery.sap.require</code> is necessary to make them available.
|
1733 | *
|
1734 | * If a caller wants to know whether a module needs to be loaded from the server,
|
1735 | * it can set <code>bIncludePreloaded</code> to true. Then, preloaded modules will
|
1736 | * be reported as 'declared' as well by this method.
|
1737 | *
|
1738 | * @param {string} sModuleName name of the module to be checked
|
1739 | * @param {boolean} [bIncludePreloaded=false] whether preloaded modules should be reported as declared.
|
1740 | * @return {boolean} whether the module has been declared already
|
1741 | * @public
|
1742 | * @static
|
1743 | * @deprecated since 1.58 use {@link sap.ui.require} instead
|
1744 | */
|
1745 | jQuery.sap.isDeclared = function isDeclared(sModuleName, bIncludePreloaded) {
|
1746 | var state = _ui5loader.getModuleState( ui5ToRJS(sModuleName) + ".js" );
|
1747 | return state && (bIncludePreloaded || state > 0);
|
1748 | };
|
1749 |
|
1750 | /**
|
1751 | * Whether the given resource has been loaded (or preloaded).
|
1752 | * @param {string} sResourceName Name of the resource to check, in unified resource name format
|
1753 | * @returns {boolean} Whether the resource has been loaded already
|
1754 | * @private
|
1755 | * @ui5-restricted sap.ui.core
|
1756 | * @deprecated since 1.58
|
1757 | */
|
1758 | jQuery.sap.isResourceLoaded = function isResourceLoaded(sResourceName) {
|
1759 | return !!_ui5loader.getModuleState(sResourceName);
|
1760 | };
|
1761 |
|
1762 | /**
|
1763 | * Returns the names of all declared modules.
|
1764 | * @return {string[]} the names of all declared modules
|
1765 | * @see jQuery.sap.isDeclared
|
1766 | * @public
|
1767 | * @static
|
1768 | * @deprecated since 1.58
|
1769 | */
|
1770 | jQuery.sap.getAllDeclaredModules = LoaderExtensions.getAllRequiredModules;
|
1771 |
|
1772 |
|
1773 | // take resource roots from configuration
|
1774 | var paths = {};
|
1775 | for ( var n in oCfgData.resourceroots ) {
|
1776 | paths[ui5ToRJS(n)] = oCfgData.resourceroots[n] || ".";
|
1777 | }
|
1778 | ui5loader.config({paths: paths});
|
1779 |
|
1780 | var mUrlPrefixes = _ui5loader.getUrlPrefixes();
|
1781 | // dump the URL prefixes
|
1782 | oLog.info("URL prefixes set to:");
|
1783 | for (var n in mUrlPrefixes) {
|
1784 | oLog.info(" " + (n ? "'" + n + "'" : "(default)") + " : " + mUrlPrefixes[n]);
|
1785 | }
|
1786 |
|
1787 | /**
|
1788 | * Declares a module as existing.
|
1789 | *
|
1790 | * By default, this function assumes that the module will create a JavaScript object
|
1791 | * with the same name as the module. As a convenience it ensures that the parent
|
1792 | * namespace for that object exists (by calling jQuery.sap.getObject).
|
1793 | * If such an object creation is not desired, <code>bCreateNamespace</code> must be set to false.
|
1794 | *
|
1795 | * @param {string | object} sModuleName name of the module to be declared
|
1796 | * or in case of an object {modName: "...", type: "..."}
|
1797 | * where modName is the name of the module and the type
|
1798 | * could be a specific dot separated extension e.g.
|
1799 | * <code>{modName: "sap.ui.core.Dev", type: "view"}</code>
|
1800 | * loads <code>sap/ui/core/Dev.view.js</code> and
|
1801 | * registers as <code>sap.ui.core.Dev.view</code>
|
1802 | * @param {boolean} [bCreateNamespace=true] whether to create the parent namespace
|
1803 | *
|
1804 | * @public
|
1805 | * @static
|
1806 | * @deprecated As of 1.52, UI5 modules and their dependencies should be defined using {@link sap.ui.define}.
|
1807 | * For more details see {@link topic:91f23a736f4d1014b6dd926db0e91070 Modules and Dependencies} in the
|
1808 | * documentation.
|
1809 | */
|
1810 | jQuery.sap.declare = function(sModuleName, bCreateNamespace) {
|
1811 |
|
1812 | var sNamespaceObj = sModuleName;
|
1813 |
|
1814 | // check for an object as parameter for sModuleName
|
1815 | // in case of this the object contains the module name and the type
|
1816 | // which could be {modName: "sap.ui.core.Dev", type: "view"}
|
1817 | if (typeof (sModuleName) === "object") {
|
1818 | sNamespaceObj = sModuleName.modName;
|
1819 | sModuleName = ui5ToRJS(sModuleName.modName) + (sModuleName.type ? "." + sModuleName.type : "") + ".js";
|
1820 | } else {
|
1821 | sModuleName = ui5ToRJS(sModuleName) + ".js";
|
1822 | }
|
1823 |
|
1824 | _ui5loader.declareModule(sModuleName);
|
1825 |
|
1826 | // ensure parent namespace even if module was declared already
|
1827 | // (as declare might have been called by require)
|
1828 | if (bCreateNamespace !== false) {
|
1829 | // ensure parent namespace
|
1830 | jQuery.sap.getObject(sNamespaceObj, 1);
|
1831 | }
|
1832 |
|
1833 | };
|
1834 |
|
1835 | /**
|
1836 | * Ensures that the given module is loaded and executed before execution of the
|
1837 | * current script continues.
|
1838 | *
|
1839 | * By issuing a call to this method, the caller declares a dependency to the listed modules.
|
1840 | *
|
1841 | * Any required and not yet loaded script will be loaded and execute synchronously.
|
1842 | * Already loaded modules will be skipped.
|
1843 | *
|
1844 | * @param {...string | object} vModuleName one or more names of modules to be loaded
|
1845 | * or in case of an object {modName: "...", type: "..."}
|
1846 | * where modName is the name of the module and the type
|
1847 | * could be a specific dot separated extension e.g.
|
1848 | * <code>{modName: "sap.ui.core.Dev", type: "view"}</code>
|
1849 | * loads <code>sap/ui/core/Dev.view.js</code> and
|
1850 | * registers as <code>sap.ui.core.Dev.view</code>
|
1851 | *
|
1852 | * @public
|
1853 | * @static
|
1854 | * @function
|
1855 | * @SecSink {0|PATH} Parameter is used for future HTTP requests
|
1856 | * @deprecated As of 1.52, UI5 modules and their dependencies should be defined using {@link sap.ui.define}.
|
1857 | * When additional modules have to be loaded dynamically at a later point in time, the asynchronous API
|
1858 | * {@link sap.ui.require} should be used. For more details, see {@link topic:91f23a736f4d1014b6dd926db0e91070
|
1859 | * Modules and Dependencies} in the documentation.
|
1860 | */
|
1861 | jQuery.sap.require = function(vModuleName) {
|
1862 |
|
1863 | if ( arguments.length > 1 ) {
|
1864 | // legacy mode with multiple arguments, each representing a dependency
|
1865 | for (var i = 0; i < arguments.length; i++) {
|
1866 | jQuery.sap.require(arguments[i]);
|
1867 | }
|
1868 | return this;
|
1869 | }
|
1870 |
|
1871 | // check for an object as parameter for sModuleName
|
1872 | // in case of this the object contains the module name and the type
|
1873 | // which could be {modName: "sap.ui.core.Dev", type: "view"}
|
1874 | if (typeof (vModuleName) === "object") {
|
1875 | jQuery.sap.assert(!vModuleName.type || mKnownSubtypes.js.indexOf(vModuleName.type) >= 0, "type must be empty or one of " + mKnownSubtypes.js.join(", "));
|
1876 | vModuleName = ui5ToRJS(vModuleName.modName) + (vModuleName.type ? "." + vModuleName.type : "");
|
1877 | } else {
|
1878 | vModuleName = ui5ToRJS(vModuleName);
|
1879 | }
|
1880 |
|
1881 | sap.ui.requireSync(vModuleName);
|
1882 |
|
1883 | };
|
1884 |
|
1885 | // propagate legacy require hook to ui5loader translate hook
|
1886 | Object.defineProperty(jQuery.sap.require, "_hook", {
|
1887 | get: function() {
|
1888 | return _ui5loader.translate;
|
1889 | },
|
1890 | set: function(hook) {
|
1891 | jQuery.sap.assert(false, "jquery.sap.global: legacy hook for code transformation should no longer be used");
|
1892 | _ui5loader.translate = hook;
|
1893 | }
|
1894 | });
|
1895 |
|
1896 | /**
|
1897 | * @private
|
1898 | * @deprecated
|
1899 | */
|
1900 | jQuery.sap.preloadModules = function(sPreloadModule, bAsync, oSyncPoint) {
|
1901 | Log.error("jQuery.sap.preloadModules was never a public API and has been removed. Migrate to Core.loadLibrary()!");
|
1902 | };
|
1903 |
|
1904 | /**
|
1905 | * Adds all resources from a preload bundle to the preload cache.
|
1906 | *
|
1907 | * When a resource exists already in the cache, the new content is ignored.
|
1908 | *
|
1909 | * @param {object} oData Preload bundle
|
1910 | * @param {string} [oData.url] URL from which the bundle has been loaded
|
1911 | * @param {string} [oData.name] Unique name of the bundle
|
1912 | * @param {string} [oData.version='1.0'] Format version of the preload bundle
|
1913 | * @param {object} oData.modules Map of resources keyed by their resource name; each resource must be a string or a function
|
1914 | *
|
1915 | * @private
|
1916 | * @ui5-restricted sap.ui.core,preloadfiles
|
1917 | * @deprecated since 1.58
|
1918 | */
|
1919 | jQuery.sap.registerPreloadedModules = function(oData) {
|
1920 |
|
1921 | var modules = oData.modules;
|
1922 | if ( Version(oData.version || "1.0").compareTo("2.0") < 0 ) {
|
1923 | modules = {};
|
1924 | for ( var sName in oData.modules ) {
|
1925 | modules[ui5ToRJS(sName) + ".js"] = oData.modules[sName];
|
1926 | }
|
1927 | }
|
1928 | sap.ui.require.preload(modules, oData.name, oData.url);
|
1929 |
|
1930 | };
|
1931 |
|
1932 | /**
|
1933 | * Removes a set of resources from the resource cache.
|
1934 | *
|
1935 | * @param {string} sName unified resource name of a resource or the name of a preload group to be removed
|
1936 | * @param {boolean} [bPreloadGroup=true] whether the name specifies a preload group, defaults to true
|
1937 | * @param {boolean} [bUnloadAll] Whether all matching resources should be unloaded, even if they have been executed already.
|
1938 | * @param {boolean} [bDeleteExports] Whether exports (global variables) should be destroyed as well. Will be done for UI5 module names only.
|
1939 | * @experimental Since 1.16.3 API might change completely, apps must not develop against it.
|
1940 | * @private
|
1941 | * @function
|
1942 | * @deprecated since 1.58
|
1943 | */
|
1944 | jQuery.sap.unloadResources = _ui5loader.unloadResources;
|
1945 |
|
1946 | /**
|
1947 | * Converts a UI5 module name to a unified resource name.
|
1948 | *
|
1949 | * Used by View and Fragment APIs to convert a given module name into a unified resource name.
|
1950 | * When the <code>sSuffix</code> is not given, the suffix '.js' is added. This fits the most
|
1951 | * common use case of converting a module name to the Javascript resource that contains the
|
1952 | * module. Note that an empty <code>sSuffix</code> is not replaced by '.js'. This allows to
|
1953 | * convert UI5 module names to requireJS module names with a call to this method.
|
1954 | *
|
1955 | * @param {string} sModuleName Module name as a dot separated name
|
1956 | * @param {string} [sSuffix='.js'] Suffix to add to the final resource name
|
1957 | * @private
|
1958 | * @ui5-restricted sap.ui.core
|
1959 | * @deprecated since 1.58
|
1960 | */
|
1961 | jQuery.sap.getResourceName = function(sModuleName, sSuffix) {
|
1962 | return ui5ToRJS(sModuleName) + (sSuffix == null ? ".js" : sSuffix);
|
1963 | };
|
1964 |
|
1965 | /**
|
1966 | * Retrieves the resource with the given name, either from the preload cache or from
|
1967 | * the server. The expected data type of the resource can either be specified in the
|
1968 | * options (<code>dataType</code>) or it will be derived from the suffix of the <code>sResourceName</code>.
|
1969 | * The only supported data types so far are xml, html, json and text. If the resource name extension
|
1970 | * doesn't match any of these extensions, the data type must be specified in the options.
|
1971 | *
|
1972 | * If the resource is found in the preload cache, it will be converted from text format
|
1973 | * to the requested <code>dataType</code> using a converter from <code>jQuery.ajaxSettings.converters</code>.
|
1974 | *
|
1975 | * If it is not found, the resource name will be converted to a resource URL (using {@link #getResourcePath})
|
1976 | * and the resulting URL will be requested from the server with a synchronous jQuery.ajax call.
|
1977 | *
|
1978 | * If the resource was found in the local preload cache and any necessary conversion succeeded
|
1979 | * or when the resource was retrieved from the backend successfully, the content of the resource will
|
1980 | * be returned. In any other case, an exception will be thrown, or if option failOnError is set to true,
|
1981 | * <code>null</code> will be returned.
|
1982 | *
|
1983 | * Future implementations of this API might add more options. Generic implementations that accept an
|
1984 | * <code>mOptions</code> object and propagate it to this function should limit the options to the currently
|
1985 | * defined set of options or they might fail for unknown options.
|
1986 | *
|
1987 | * For asynchronous calls the return value of this method is an ECMA Script 6 Promise object which callbacks are triggered
|
1988 | * when the resource is ready:
|
1989 | * If <code>failOnError</code> is <code>false</code> the catch callback of the promise is not called. The argument given to the fullfilled
|
1990 | * callback is null in error case.
|
1991 | * If <code>failOnError</code> is <code>true</code> the catch callback will be triggered. The argument is an Error object in this case.
|
1992 | *
|
1993 | * @param {string} [sResourceName] resourceName in unified resource name syntax
|
1994 | * @param {object} [mOptions] options
|
1995 | * @param {object} [mOptions.dataType] one of "xml", "html", "json" or "text". If not specified it will be derived from the resource name (extension)
|
1996 | * @param {string} [mOptions.name] unified resource name of the resource to load (alternative syntax)
|
1997 | * @param {string} [mOptions.url] url of a resource to load (alternative syntax, name will only be a guess)
|
1998 | * @param {string} [mOptions.headers] Http headers for an eventual XHR request
|
1999 | * @param {string} [mOptions.failOnError=true] whether to propagate load errors or not
|
2000 | * @param {string} [mOptions.async=false] whether the loading should be performed asynchronously.
|
2001 | * @return {string|Document|object|Promise} content of the resource. A string for text or html, an Object for JSON, a Document for XML. For asynchronous calls an ECMA Script 6 Promise object will be returned.
|
2002 | * @throws Error if loading the resource failed
|
2003 | * @private
|
2004 | * @experimental API is not yet fully mature and may change in future.
|
2005 | * @since 1.15.1
|
2006 | * @deprecated since 1.58
|
2007 | */
|
2008 | jQuery.sap.loadResource = LoaderExtensions.loadResource;
|
2009 |
|
2010 | /*
|
2011 | * register a global event handler to detect script execution errors.
|
2012 | * Only works for browsers that support document.currentScript.
|
2013 | * /
|
2014 | window.addEventListener("error", function(e) {
|
2015 | if ( document.currentScript && document.currentScript.dataset.sapUiModule ) {
|
2016 | var error = {
|
2017 | message: e.message,
|
2018 | filename: e.filename,
|
2019 | lineno: e.lineno,
|
2020 | colno: e.colno
|
2021 | };
|
2022 | document.currentScript.dataset.sapUiModuleError = JSON.stringify(error);
|
2023 | }
|
2024 | });
|
2025 | */
|
2026 |
|
2027 | /**
|
2028 | * Loads the given Javascript resource (URN) asynchronously via as script tag.
|
2029 | * Returns a promise that will be resolved when the load event is fired or reject
|
2030 | * when the error event is fired.
|
2031 | *
|
2032 | * Note: execution errors of the script are not reported as 'error'.
|
2033 | *
|
2034 | * This method is not a full implementation of require. It is intended only for
|
2035 | * loading "preload" files that do not define an own module / module value.
|
2036 | *
|
2037 | * Functionality might be removed/renamed in future, so no code outside the
|
2038 | * sap.ui.core library must use it.
|
2039 | *
|
2040 | * @experimental
|
2041 | * @private
|
2042 | * @ui5-restricted sap.ui.core,sap.ushell
|
2043 | * @deprecated since 1.58
|
2044 | */
|
2045 | jQuery.sap._loadJSResourceAsync = _ui5loader.loadJSResourceAsync;
|
2046 |
|
2047 | return function() {
|
2048 | return {
|
2049 | modules : _ui5loader.getAllModules(),
|
2050 | prefixes : _ui5loader.getUrlPrefixes()
|
2051 | };
|
2052 | };
|
2053 |
|
2054 | }());
|
2055 |
|
2056 | // --------------------- script and stylesheet handling --------------------------------------------------
|
2057 |
|
2058 | /**
|
2059 | * Includes the script (via <script>-tag) into the head for the
|
2060 | * specified <code>sUrl</code> and optional <code>sId</code>.
|
2061 | *
|
2062 | * @param {string|object}
|
2063 | * vUrl the URL of the script to load or a configuration object
|
2064 | * @param {string}
|
2065 | * vUrl.url the URL of the script to load
|
2066 | * @param {string}
|
2067 | * [vUrl.id] id that should be used for the script tag
|
2068 | * @param {object}
|
2069 | * [vUrl.attributes] map of attributes that should be used for the script tag
|
2070 | * @param {string|object}
|
2071 | * [vId] id that should be used for the script tag or map of attributes
|
2072 | * @param {function}
|
2073 | * [fnLoadCallback] callback function to get notified once the script has been loaded
|
2074 | * @param {function}
|
2075 | * [fnErrorCallback] callback function to get notified once the script loading failed
|
2076 | * @return {void|Promise}
|
2077 | * When using the configuration object a <code>Promise</code> will be returned. The
|
2078 | * documentation for the <code>fnLoadCallback</code> applies to the <code>resolve</code>
|
2079 | * handler of the <code>Promise</code> and the one for the <code>fnErrorCallback</code>
|
2080 | * applies to the <code>reject</code> handler of the <code>Promise</code>.
|
2081 | *
|
2082 | * @public
|
2083 | * @static
|
2084 | * @function
|
2085 | * @deprecated since 1.58 use {@link module:sap/ui/dom/includeScript} instead
|
2086 | * @SecSink {0|PATH} Parameter is used for future HTTP requests
|
2087 | */
|
2088 | jQuery.sap.includeScript = includeScript;
|
2089 |
|
2090 |
|
2091 | /**
|
2092 | * Includes the specified stylesheet via a <link>-tag in the head of the current document. If there is call to
|
2093 | * <code>includeStylesheet</code> providing the sId of an already included stylesheet, the existing element will be
|
2094 | * replaced.
|
2095 | *
|
2096 | * @param {string|object}
|
2097 | * vUrl the URL of the stylesheet to load or a configuration object
|
2098 | * @param {string}
|
2099 | * vUrl.url the URL of the stylesheet to load
|
2100 | * @param {string}
|
2101 | * [vUrl.id] id that should be used for the link tag
|
2102 | * @param {object}
|
2103 | * [vUrl.attributes] map of attributes that should be used for the script tag
|
2104 | * @param {string|object}
|
2105 | * [vId] id that should be used for the link tag or map of attributes
|
2106 | * @param {function}
|
2107 | * [fnLoadCallback] callback function to get notified once the stylesheet has been loaded
|
2108 | * @param {function}
|
2109 | * [fnErrorCallback] callback function to get notified once the stylesheet loading failed.
|
2110 | * @return {void|Promise}
|
2111 | * When using the configuration object a <code>Promise</code> will be returned. The
|
2112 | * documentation for the <code>fnLoadCallback</code> applies to the <code>resolve</code>
|
2113 | * handler of the <code>Promise</code> and the one for the <code>fnErrorCallback</code>
|
2114 | * applies to the <code>reject</code> handler of the <code>Promise</code>.
|
2115 | *
|
2116 | * @public
|
2117 | * @static
|
2118 | * @function
|
2119 | * @deprecated since 1.58 use {@link module:sap/ui/dom/includeStylesheet} instead
|
2120 | * @SecSink {0|PATH} Parameter is used for future HTTP requests
|
2121 | */
|
2122 | jQuery.sap.includeStyleSheet = includeStylesheet;
|
2123 |
|
2124 | // --------------------- support hooks ---------------------------------------------------------
|
2125 |
|
2126 | // TODO should be in core, but then the 'callback' could not be implemented
|
2127 | if ( !(oCfgData.productive === true || oCfgData.productive === "true" || oCfgData.productive === "x") ) {
|
2128 | SupportHotkeys.init(getModuleSystemInfo, oCfgData);
|
2129 | TestRecorderHotkeyListener.init(getModuleSystemInfo, oCfgData);
|
2130 | }
|
2131 |
|
2132 | // -----------------------------------------------------------------------
|
2133 |
|
2134 | if ( oJQVersion.compareTo("3.6.0") != 0 ) {
|
2135 | // if the loaded jQuery version isn't SAPUI5's default version -> notify
|
2136 | // the application
|
2137 | Log.warning("SAPUI5's default jQuery version is 3.6.0; current version is " + jQuery.fn.jquery + ". Please note that we only support version 3.6.0.");
|
2138 | }
|
2139 |
|
2140 | // --------------------- frame protection -------------------------------------------------------
|
2141 |
|
2142 | /**
|
2143 | * @deprecated since 1.58 use {@link module:sap/ui/security/FrameOptions} instead
|
2144 | */
|
2145 | jQuery.sap.FrameOptions = FrameOptions;
|
2146 |
|
2147 | /**
|
2148 | * Executes an 'eval' for its arguments in the global context (without closure variables).
|
2149 | *
|
2150 | * This is a synchronous replacement for <code>jQuery.globalEval</code> which in some
|
2151 | * browsers (e.g. FireFox) behaves asynchronously.
|
2152 | *
|
2153 | * @type void
|
2154 | * @public
|
2155 | * @static
|
2156 | * @deprecated since 1.58
|
2157 | * @SecSink {0|XSS} Parameter is evaluated
|
2158 | */
|
2159 | jQuery.sap.globalEval = function() {
|
2160 |
|
2161 | /*eslint-disable no-eval */
|
2162 | eval(arguments[0]);
|
2163 | /*eslint-enable no-eval */
|
2164 | };
|
2165 |
|
2166 | (function() {
|
2167 |
|
2168 | var b = Device.browser;
|
2169 | var id = b.name;
|
2170 |
|
2171 | // TODO move to a separate module? Only adds 385 bytes (compressed), but...
|
2172 | if ( !jQuery.browser ) {
|
2173 | // re-introduce the jQuery.browser support if missing (jQuery-1.9ff)
|
2174 | jQuery.browser = (function (ua) {
|
2175 |
|
2176 | var rwebkit = /(webkit)[ \/]([\w.]+)/,
|
2177 | ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
2178 | rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
2179 | ua = ua.toLowerCase(),
|
2180 | match = rwebkit.exec(ua) ||
|
2181 | ropera.exec(ua) ||
|
2182 | ua.indexOf("compatible") < 0 && rmozilla.exec(ua) ||
|
2183 | [],
|
2184 | browser = {};
|
2185 |
|
2186 | if (match[1]) {
|
2187 | browser[match[1]] = true;
|
2188 | browser.version = match[2] || "0";
|
2189 | if (browser.webkit) {
|
2190 | browser.safari = true;
|
2191 | }
|
2192 | }
|
2193 |
|
2194 | return browser;
|
2195 |
|
2196 | }(window.navigator.userAgent));
|
2197 | }
|
2198 |
|
2199 | if (id === b.BROWSER.CHROME) {
|
2200 | jQuery.browser.safari = false;
|
2201 | jQuery.browser.chrome = true;
|
2202 | } else if (id === b.BROWSER.SAFARI) {
|
2203 | jQuery.browser.safari = true;
|
2204 | jQuery.browser.chrome = false;
|
2205 | }
|
2206 |
|
2207 | if (id) {
|
2208 | jQuery.browser.fVersion = b.version;
|
2209 | jQuery.browser.mobile = b.mobile;
|
2210 | }
|
2211 |
|
2212 | }());
|
2213 |
|
2214 | return jQuery;
|
2215 | });
|