1
1
import { registerFeature } from "../FeaturesRegistry.js" ;
2
2
import { setTheme } from "../config/Theme.js" ;
3
+ import { getCurrentZIndex } from "../util/PopupUtils.js" ;
3
4
4
- const sap = window . sap ;
5
- const core = sap && sap . ui && typeof sap . ui . getCore === "function" && sap . ui . getCore ( ) ;
5
+ const getCore = ( ) => {
6
+ const sap = window . sap ;
7
+ const core = sap && sap . ui && typeof sap . ui . getCore === "function" && sap . ui . getCore ( ) ;
8
+ return core ;
9
+ } ;
6
10
7
11
const isLoaded = ( ) => {
8
- return ! ! core ;
12
+ return ! ! getCore ( ) ;
9
13
} ;
10
14
11
15
const init = ( ) => {
16
+ const core = getCore ( ) ;
12
17
if ( ! core ) {
13
18
return Promise . resolve ( ) ;
14
19
}
15
20
16
21
return new Promise ( resolve => {
17
22
core . attachInit ( ( ) => {
18
- sap . ui . require ( [ "sap/ui/core/LocaleData" ] , resolve ) ;
23
+ window . sap . ui . require ( [ "sap/ui/core/LocaleData" , "sap/ui/core/Popup" ] , ( LocaleData , Popup ) => {
24
+ Popup . setInitialZIndex ( getCurrentZIndex ( ) ) ;
25
+ resolve ( ) ;
26
+ } ) ;
19
27
} ) ;
20
28
} ) ;
21
29
} ;
22
30
23
31
const getConfigurationSettingsObject = ( ) => {
32
+ const core = getCore ( ) ;
24
33
if ( ! core ) {
25
34
return ;
26
35
}
27
36
28
37
const config = core . getConfiguration ( ) ;
29
- const LocaleData = sap . ui . require ( "sap/ui/core/LocaleData" ) ;
38
+ const LocaleData = window . sap . ui . require ( "sap/ui/core/LocaleData" ) ;
30
39
31
40
return {
32
41
animationMode : config . getAnimationMode ( ) ,
@@ -41,23 +50,26 @@ const getConfigurationSettingsObject = () => {
41
50
} ;
42
51
43
52
const getLocaleDataObject = ( ) => {
53
+ const core = getCore ( ) ;
44
54
if ( ! core ) {
45
55
return ;
46
56
}
47
57
48
58
const config = core . getConfiguration ( ) ;
49
- const LocaleData = sap . ui . require ( "sap/ui/core/LocaleData" ) ;
59
+ const LocaleData = window . sap . ui . require ( "sap/ui/core/LocaleData" ) ;
50
60
return LocaleData . getInstance ( config . getLocale ( ) ) . _get ( ) ;
51
61
} ;
52
62
53
63
const listenForThemeChange = ( ) => {
64
+ const core = getCore ( ) ;
54
65
const config = core . getConfiguration ( ) ;
55
66
core . attachThemeChanged ( async ( ) => {
56
67
await setTheme ( config . getTheme ( ) ) ;
57
68
} ) ;
58
69
} ;
59
70
60
71
const attachListeners = ( ) => {
72
+ const core = getCore ( ) ;
61
73
if ( ! core ) {
62
74
return ;
63
75
}
@@ -66,6 +78,7 @@ const attachListeners = () => {
66
78
} ;
67
79
68
80
const cssVariablesLoaded = ( ) => {
81
+ const core = getCore ( ) ;
69
82
if ( ! core ) {
70
83
return ;
71
84
}
@@ -78,13 +91,35 @@ const cssVariablesLoaded = () => {
78
91
return ! ! link . href . match ( / \/ c s s ( - | _ ) v a r i a b l e s \. c s s / ) ;
79
92
} ;
80
93
94
+ const getNextZIndex = ( ) => {
95
+ const core = getCore ( ) ;
96
+ if ( ! core ) {
97
+ return ;
98
+ }
99
+
100
+ const Popup = window . sap . ui . require ( "sap/ui/core/Popup" ) ;
101
+ return Popup . getNextZIndex ( ) ;
102
+ } ;
103
+
104
+ const setInitialZIndex = ( ) => {
105
+ const core = getCore ( ) ;
106
+ if ( ! core ) {
107
+ return ;
108
+ }
109
+
110
+ const Popup = window . sap . ui . require ( "sap/ui/core/Popup" ) ;
111
+ Popup . setInitialZIndex ( getCurrentZIndex ( ) ) ;
112
+ } ;
113
+
81
114
const OpenUI5Support = {
82
115
isLoaded,
83
116
init,
84
117
getConfigurationSettingsObject,
85
118
getLocaleDataObject,
86
119
attachListeners,
87
120
cssVariablesLoaded,
121
+ getNextZIndex,
122
+ setInitialZIndex,
88
123
} ;
89
124
90
125
registerFeature ( "OpenUI5Support" , OpenUI5Support ) ;
0 commit comments