@openui5/sap.ui.core 1.107.0 → 1.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/.dtsgenrc +63 -0
  2. package/THIRDPARTY.txt +1 -1
  3. package/package.json +1 -1
  4. package/src/jquery.sap.global.js +1 -1
  5. package/src/jquery.sap.properties.js +1 -1
  6. package/src/jquery.sap.resources.js +1 -1
  7. package/src/jquery.sap.script.js +1 -1
  8. package/src/jquery.sap.storage.js +3 -3
  9. package/src/sap/base/i18n/ResourceBundle.js +10 -0
  10. package/src/sap/base/security/URLListValidator.js +36 -3
  11. package/src/sap/base/util/restricted/_CancelablePromise.js +1 -1
  12. package/src/sap/base/util/restricted/_castArray.js +1 -1
  13. package/src/sap/base/util/restricted/_compact.js +1 -1
  14. package/src/sap/base/util/restricted/_curry.js +1 -1
  15. package/src/sap/base/util/restricted/_debounce.js +1 -1
  16. package/src/sap/base/util/restricted/_difference.js +1 -1
  17. package/src/sap/base/util/restricted/_differenceBy.js +1 -1
  18. package/src/sap/base/util/restricted/_differenceWith.js +1 -1
  19. package/src/sap/base/util/restricted/_flatMap.js +1 -1
  20. package/src/sap/base/util/restricted/_flatMapDeep.js +1 -1
  21. package/src/sap/base/util/restricted/_flatMapDepth.js +1 -1
  22. package/src/sap/base/util/restricted/_flatten.js +1 -1
  23. package/src/sap/base/util/restricted/_flattenDeep.js +1 -1
  24. package/src/sap/base/util/restricted/_flattenDepth.js +1 -1
  25. package/src/sap/base/util/restricted/_intersection.js +1 -1
  26. package/src/sap/base/util/restricted/_intersectionBy.js +1 -1
  27. package/src/sap/base/util/restricted/_intersectionWith.js +1 -1
  28. package/src/sap/base/util/restricted/_isEqual.js +1 -1
  29. package/src/sap/base/util/restricted/_isEqualWith.js +1 -1
  30. package/src/sap/base/util/restricted/_isNil.js +1 -1
  31. package/src/sap/base/util/restricted/_max.js +1 -1
  32. package/src/sap/base/util/restricted/_merge.js +1 -1
  33. package/src/sap/base/util/restricted/_mergeWith.js +1 -1
  34. package/src/sap/base/util/restricted/_min.js +1 -1
  35. package/src/sap/base/util/restricted/_omit.js +1 -1
  36. package/src/sap/base/util/restricted/_pick.js +1 -1
  37. package/src/sap/base/util/restricted/_pickBy.js +1 -1
  38. package/src/sap/base/util/restricted/_throttle.js +1 -1
  39. package/src/sap/base/util/restricted/_toArray.js +1 -1
  40. package/src/sap/base/util/restricted/_union.js +1 -1
  41. package/src/sap/base/util/restricted/_unionBy.js +1 -1
  42. package/src/sap/base/util/restricted/_unionWith.js +1 -1
  43. package/src/sap/base/util/restricted/_uniq.js +1 -1
  44. package/src/sap/base/util/restricted/_uniqBy.js +1 -1
  45. package/src/sap/base/util/restricted/_uniqWith.js +1 -1
  46. package/src/sap/base/util/restricted/_without.js +1 -1
  47. package/src/sap/base/util/restricted/_xor.js +1 -1
  48. package/src/sap/base/util/restricted/_xorBy.js +1 -1
  49. package/src/sap/base/util/restricted/_xorWith.js +1 -1
  50. package/src/sap/base/util/restricted/_zipObject.js +1 -1
  51. package/src/sap/base/util/restricted/_zipObjectDeep.js +1 -1
  52. package/src/sap/ui/Device.js +3 -3
  53. package/src/sap/ui/Global.js +4 -4
  54. package/src/sap/ui/base/Event.js +1 -1
  55. package/src/sap/ui/base/EventProvider.js +1 -1
  56. package/src/sap/ui/base/Interface.js +1 -1
  57. package/src/sap/ui/base/ManagedObject.js +2 -2
  58. package/src/sap/ui/base/ManagedObjectMetadata.js +1 -1
  59. package/src/sap/ui/base/Metadata.js +1 -1
  60. package/src/sap/ui/base/Object.js +1 -1
  61. package/src/sap/ui/base/ObjectPool.js +1 -1
  62. package/src/sap/ui/core/.library +50 -50
  63. package/src/sap/ui/core/BusyIndicator.js +1 -1
  64. package/src/sap/ui/core/BusyIndicatorUtils.js +22 -8
  65. package/src/sap/ui/core/Component.js +21 -4
  66. package/src/sap/ui/core/ComponentContainer.js +5 -1
  67. package/src/sap/ui/core/ComponentMetadata.js +1 -1
  68. package/src/sap/ui/core/ComponentSupport.js +1 -1
  69. package/src/sap/ui/core/Configuration.js +2 -15
  70. package/src/sap/ui/core/Control.js +20 -2
  71. package/src/sap/ui/core/Core.js +311 -413
  72. package/src/sap/ui/core/CustomData.js +1 -1
  73. package/src/sap/ui/core/DeclarativeSupport.js +1 -1
  74. package/src/sap/ui/core/Element.js +1 -1
  75. package/src/sap/ui/core/ElementMetadata.js +1 -1
  76. package/src/sap/ui/core/EnabledPropagator.js +1 -1
  77. package/src/sap/ui/core/EventBus.js +1 -1
  78. package/src/sap/ui/core/FocusHandler.js +12 -14
  79. package/src/sap/ui/core/Fragment.js +5 -2
  80. package/src/sap/ui/core/HTML.js +1 -1
  81. package/src/sap/ui/core/History.js +1 -1
  82. package/src/sap/ui/core/Icon.js +1 -1
  83. package/src/sap/ui/core/IconPool.js +7 -1
  84. package/src/sap/ui/core/IndicationColorSupport.js +1 -1
  85. package/src/sap/ui/core/IntervalTrigger.js +1 -1
  86. package/src/sap/ui/core/InvisibleMessage.js +1 -1
  87. package/src/sap/ui/core/InvisibleRenderer.js +1 -1
  88. package/src/sap/ui/core/InvisibleText.js +1 -1
  89. package/src/sap/ui/core/Item.js +1 -1
  90. package/src/sap/ui/core/LabelEnablement.js +1 -1
  91. package/src/sap/ui/core/LayoutData.js +1 -1
  92. package/src/sap/ui/core/ListItem.js +1 -1
  93. package/src/sap/ui/core/LocalBusyIndicator.js +1 -1
  94. package/src/sap/ui/core/Locale.js +1 -1
  95. package/src/sap/ui/core/LocaleData.js +1 -1
  96. package/src/sap/ui/core/Manifest.js +16 -83
  97. package/src/sap/ui/core/Message.js +1 -1
  98. package/src/sap/ui/core/Popup.js +14 -4
  99. package/src/sap/ui/core/RenderManager.js +111 -109
  100. package/src/sap/ui/core/Renderer.js +1 -1
  101. package/src/sap/ui/core/ResizeHandler.js +1 -1
  102. package/src/sap/ui/core/ScrollBar.js +1 -1
  103. package/src/sap/ui/core/SeparatorItem.js +1 -1
  104. package/src/sap/ui/core/ShortcutHintsMixin.js +20 -0
  105. package/src/sap/ui/core/Title.js +1 -1
  106. package/src/sap/ui/core/TooltipBase.js +1 -1
  107. package/src/sap/ui/core/UIArea.js +4 -2
  108. package/src/sap/ui/core/UIComponent.js +1 -1
  109. package/src/sap/ui/core/UIComponentMetadata.js +1 -1
  110. package/src/sap/ui/core/ValueStateSupport.js +1 -1
  111. package/src/sap/ui/core/VariantLayoutData.js +1 -1
  112. package/src/sap/ui/core/XMLComposite.js +1 -1
  113. package/src/sap/ui/core/XMLCompositeMetadata.js +1 -1
  114. package/src/sap/ui/core/_IconRegistry.js +11 -7
  115. package/src/sap/ui/core/_UrlResolver.js +139 -0
  116. package/src/sap/ui/core/date/CalendarUtils.js +87 -0
  117. package/src/sap/ui/core/date/CalendarWeekNumbering.js +73 -0
  118. package/src/sap/ui/core/date/UniversalDate.js +198 -74
  119. package/src/sap/ui/core/delegate/ItemNavigation.js +1 -1
  120. package/src/sap/ui/core/delegate/ScrollEnablement.js +1 -1
  121. package/src/sap/ui/core/dnd/DragDropBase.js +1 -1
  122. package/src/sap/ui/core/dnd/DragDropInfo.js +1 -1
  123. package/src/sap/ui/core/dnd/DragInfo.js +1 -1
  124. package/src/sap/ui/core/dnd/DropInfo.js +1 -1
  125. package/src/sap/ui/core/format/DateFormat.js +187 -57
  126. package/src/sap/ui/core/format/NumberFormat.js +64 -23
  127. package/src/sap/ui/core/format/TimezoneUtil.js +3 -1
  128. package/src/sap/ui/core/hyphenation/Hyphenation.js +1 -1
  129. package/src/sap/ui/core/library.js +19 -10
  130. package/src/sap/ui/core/message/ControlMessageProcessor.js +1 -1
  131. package/src/sap/ui/core/message/Message.js +5 -3
  132. package/src/sap/ui/core/message/MessageManager.js +1 -1
  133. package/src/sap/ui/core/message/MessageParser.js +1 -1
  134. package/src/sap/ui/core/message/MessageProcessor.js +1 -1
  135. package/src/sap/ui/core/messagebundle_fr.properties +1 -1
  136. package/src/sap/ui/core/mvc/HTMLView.js +10 -2
  137. package/src/sap/ui/core/mvc/JSONView.js +1 -1
  138. package/src/sap/ui/core/mvc/JSView.js +1 -1
  139. package/src/sap/ui/core/mvc/TemplateView.js +1 -1
  140. package/src/sap/ui/core/mvc/View.js +1 -1
  141. package/src/sap/ui/core/mvc/XMLView.js +1 -1
  142. package/src/sap/ui/core/plugin/DeclarativeSupport.js +1 -1
  143. package/src/sap/ui/core/plugin/LessSupport.js +21 -20
  144. package/src/sap/ui/core/plugin/TemplatingSupport.js +1 -1
  145. package/src/sap/ui/core/postmessage/Bus.js +1 -1
  146. package/src/sap/ui/core/postmessage/confirmationDialog.js +1 -1
  147. package/src/sap/ui/core/search/OpenSearchProvider.js +1 -1
  148. package/src/sap/ui/core/search/SearchProvider.js +1 -1
  149. package/src/sap/ui/core/service/Service.js +1 -1
  150. package/src/sap/ui/core/service/ServiceFactory.js +1 -1
  151. package/src/sap/ui/core/service/ServiceFactoryRegistry.js +1 -1
  152. package/src/sap/ui/core/support/Plugin.js +1 -1
  153. package/src/sap/ui/core/support/Support.js +1 -1
  154. package/src/sap/ui/core/support/plugins/ControlTree.js +1 -1
  155. package/src/sap/ui/core/support/plugins/Interaction.js +1 -1
  156. package/src/sap/ui/core/support/plugins/LocalStorage.js +1 -1
  157. package/src/sap/ui/core/support/plugins/Performance.js +1 -1
  158. package/src/sap/ui/core/support/plugins/Selector.js +1 -1
  159. package/src/sap/ui/core/support/plugins/TechInfo.js +1 -1
  160. package/src/sap/ui/core/support/plugins/Trace.js +1 -1
  161. package/src/sap/ui/core/support/plugins/ViewInfo.js +1 -1
  162. package/src/sap/ui/core/themes/base/LocalBusyIndicator.less +3 -3
  163. package/src/sap/ui/core/themes/base/fonts/SAP-icons.woff2 +0 -0
  164. package/src/sap/ui/core/theming/Parameters.js +31 -12
  165. package/src/sap/ui/core/theming/ThemeHelper.js +56 -1
  166. package/src/sap/ui/core/theming/ThemeManager.js +817 -0
  167. package/src/sap/ui/core/tmpl/DOMAttribute.js +1 -1
  168. package/src/sap/ui/core/tmpl/DOMElement.js +1 -1
  169. package/src/sap/ui/core/tmpl/HandlebarsTemplate.js +1 -1
  170. package/src/sap/ui/core/tmpl/Template.js +1 -1
  171. package/src/sap/ui/core/tmpl/TemplateControl.js +1 -1
  172. package/src/sap/ui/core/util/AsyncHintsHelper.js +1 -1
  173. package/src/sap/ui/core/util/Export.js +1 -1
  174. package/src/sap/ui/core/util/ExportCell.js +1 -1
  175. package/src/sap/ui/core/util/ExportColumn.js +1 -1
  176. package/src/sap/ui/core/util/ExportRow.js +1 -1
  177. package/src/sap/ui/core/util/ExportType.js +1 -1
  178. package/src/sap/ui/core/util/ExportTypeCSV.js +1 -1
  179. package/src/sap/ui/core/util/File.js +1 -1
  180. package/src/sap/ui/core/util/LibraryInfo.js +1 -1
  181. package/src/sap/ui/core/util/MockServer.js +1 -1
  182. package/src/sap/ui/core/util/PasteHelper.js +1 -1
  183. package/src/sap/ui/core/util/serializer/HTMLViewSerializer.js +2 -1
  184. package/src/sap/ui/core/util/serializer/Serializer.js +1 -1
  185. package/src/sap/ui/core/util/serializer/ViewSerializer.js +1 -1
  186. package/src/sap/ui/core/util/serializer/XMLViewSerializer.js +1 -1
  187. package/src/sap/ui/core/util/serializer/delegate/Delegate.js +1 -1
  188. package/src/sap/ui/core/util/serializer/delegate/HTML.js +1 -1
  189. package/src/sap/ui/core/util/serializer/delegate/XML.js +1 -1
  190. package/src/sap/ui/core/ws/ReadyState.js +1 -1
  191. package/src/sap/ui/core/ws/SapPcpWebSocket.js +1 -1
  192. package/src/sap/ui/core/ws/WebSocket.js +1 -1
  193. package/src/sap/ui/debug/ControlTree.js +1 -1
  194. package/src/sap/ui/debug/DebugEnv.js +1 -1
  195. package/src/sap/ui/debug/PropertyList.js +1 -1
  196. package/src/sap/ui/dom/getFirstEditableInput.js +25 -6
  197. package/src/sap/ui/dom/includeStylesheet.js +2 -2
  198. package/src/sap/ui/model/ClientListBinding.js +11 -4
  199. package/src/sap/ui/model/ClientModel.js +1 -1
  200. package/src/sap/ui/model/ClientTreeBinding.js +60 -5
  201. package/src/sap/ui/model/CompositeDataState.js +1 -1
  202. package/src/sap/ui/model/CompositeType.js +1 -1
  203. package/src/sap/ui/model/DataState.js +1 -1
  204. package/src/sap/ui/model/Filter.js +6 -6
  205. package/src/sap/ui/model/MetaModel.js +1 -1
  206. package/src/sap/ui/model/Model.js +1 -1
  207. package/src/sap/ui/model/SelectionModel.js +1 -1
  208. package/src/sap/ui/model/SimpleType.js +1 -1
  209. package/src/sap/ui/model/Sorter.js +6 -4
  210. package/src/sap/ui/model/TreeAutoExpandMode.js +1 -1
  211. package/src/sap/ui/model/TreeBinding.js +18 -0
  212. package/src/sap/ui/model/TreeBindingCompatibilityAdapter.js +1 -1
  213. package/src/sap/ui/model/Type.js +1 -1
  214. package/src/sap/ui/model/analytics/AnalyticalTreeBindingAdapter.js +28 -34
  215. package/src/sap/ui/model/controlhelper/TreeBindingProxy.js +590 -0
  216. package/src/sap/ui/model/json/JSONModel.js +1 -1
  217. package/src/sap/ui/model/message/MessageModel.js +1 -1
  218. package/src/sap/ui/model/odata/ODataAnnotations.js +1 -1
  219. package/src/sap/ui/model/odata/ODataMessageParser.js +1 -1
  220. package/src/sap/ui/model/odata/ODataMetaModel.js +1 -1
  221. package/src/sap/ui/model/odata/ODataMetadata.js +1 -1
  222. package/src/sap/ui/model/odata/ODataModel.js +1 -1
  223. package/src/sap/ui/model/odata/type/Boolean.js +1 -1
  224. package/src/sap/ui/model/odata/type/Byte.js +1 -1
  225. package/src/sap/ui/model/odata/type/Currency.js +1 -1
  226. package/src/sap/ui/model/odata/type/Date.js +1 -1
  227. package/src/sap/ui/model/odata/type/DateTime.js +1 -1
  228. package/src/sap/ui/model/odata/type/DateTimeBase.js +1 -1
  229. package/src/sap/ui/model/odata/type/DateTimeOffset.js +1 -1
  230. package/src/sap/ui/model/odata/type/DateTimeWithTimezone.js +1 -1
  231. package/src/sap/ui/model/odata/type/Decimal.js +1 -1
  232. package/src/sap/ui/model/odata/type/Double.js +1 -1
  233. package/src/sap/ui/model/odata/type/Guid.js +1 -1
  234. package/src/sap/ui/model/odata/type/Int.js +1 -1
  235. package/src/sap/ui/model/odata/type/Int16.js +1 -1
  236. package/src/sap/ui/model/odata/type/Int32.js +1 -1
  237. package/src/sap/ui/model/odata/type/Int64.js +1 -1
  238. package/src/sap/ui/model/odata/type/ODataType.js +1 -1
  239. package/src/sap/ui/model/odata/type/Raw.js +1 -1
  240. package/src/sap/ui/model/odata/type/SByte.js +1 -1
  241. package/src/sap/ui/model/odata/type/Single.js +1 -1
  242. package/src/sap/ui/model/odata/type/Stream.js +1 -1
  243. package/src/sap/ui/model/odata/type/String.js +1 -1
  244. package/src/sap/ui/model/odata/type/Time.js +1 -1
  245. package/src/sap/ui/model/odata/type/TimeOfDay.js +1 -1
  246. package/src/sap/ui/model/odata/type/Unit.js +1 -1
  247. package/src/sap/ui/model/odata/v2/BatchMode.js +2 -2
  248. package/src/sap/ui/model/odata/v2/Context.js +169 -4
  249. package/src/sap/ui/model/odata/v2/ODataAnnotations.js +1 -1
  250. package/src/sap/ui/model/odata/v2/ODataListBinding.js +39 -17
  251. package/src/sap/ui/model/odata/v2/ODataModel.js +219 -82
  252. package/src/sap/ui/model/odata/v2/ODataTreeBinding.js +1 -1
  253. package/src/sap/ui/model/odata/v4/Context.js +35 -22
  254. package/src/sap/ui/model/odata/v4/ODataBinding.js +28 -22
  255. package/src/sap/ui/model/odata/v4/ODataContextBinding.js +6 -6
  256. package/src/sap/ui/model/odata/v4/ODataListBinding.js +111 -89
  257. package/src/sap/ui/model/odata/v4/ODataMetaModel.js +5 -4
  258. package/src/sap/ui/model/odata/v4/ODataModel.js +84 -46
  259. package/src/sap/ui/model/odata/v4/ODataParentBinding.js +19 -20
  260. package/src/sap/ui/model/odata/v4/ODataPropertyBinding.js +3 -3
  261. package/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js +1 -1
  262. package/src/sap/ui/model/odata/v4/lib/_AggregationCache.js +12 -5
  263. package/src/sap/ui/model/odata/v4/lib/_Cache.js +130 -64
  264. package/src/sap/ui/model/odata/v4/lib/_Helper.js +1 -1
  265. package/src/sap/ui/model/odata/v4/lib/_Requestor.js +56 -15
  266. package/src/sap/ui/model/resource/ResourceModel.js +1 -1
  267. package/src/sap/ui/model/type/Boolean.js +1 -1
  268. package/src/sap/ui/model/type/Currency.js +1 -1
  269. package/src/sap/ui/model/type/Date.js +1 -1
  270. package/src/sap/ui/model/type/DateInterval.js +1 -1
  271. package/src/sap/ui/model/type/DateTime.js +1 -1
  272. package/src/sap/ui/model/type/DateTimeInterval.js +1 -1
  273. package/src/sap/ui/model/type/FileSize.js +1 -1
  274. package/src/sap/ui/model/type/Float.js +1 -1
  275. package/src/sap/ui/model/type/Integer.js +1 -1
  276. package/src/sap/ui/model/type/String.js +1 -1
  277. package/src/sap/ui/model/type/Time.js +1 -1
  278. package/src/sap/ui/model/type/TimeInterval.js +1 -1
  279. package/src/sap/ui/model/type/Unit.js +1 -1
  280. package/src/sap/ui/model/xml/XMLModel.js +1 -1
  281. package/src/sap/ui/qunit/utils/ControlIterator.js +1 -1
  282. package/src/sap/ui/qunit/utils/MemoryLeakCheck.js +1 -1
  283. package/src/sap/ui/test/TestUtils.js +20 -0
  284. package/src/sap/ui/test/generic/TestBase.js +1 -1
  285. package/src/sap/ui/thirdparty/mobify-carousel.js +0 -4
  286. package/src/sap/ui/util/Storage.js +1 -1
  287. package/src/sap/ui/core/ThemeCheck.js +0 -389
@@ -0,0 +1,817 @@
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
+ // Provides class sap.ui.core.theming.ThemeManager
8
+ sap.ui.define([
9
+ 'sap/ui/Global',
10
+ "sap/ui/core/Element",
11
+ "sap/ui/core/Configuration",
12
+ "sap/ui/Device",
13
+ "sap/ui/base/EventProvider",
14
+ "sap/base/Log",
15
+ "sap/base/assert",
16
+ "sap/base/util/each",
17
+ 'sap/base/util/LoaderExtensions',
18
+ "sap/ui/util/ActivityDetection",
19
+ "sap/ui/dom/includeStylesheet",
20
+ "./ThemeHelper"
21
+ ],
22
+ function(Global, Element, Configuration, Device, EventProvider, Log, assert, each, LoaderExtensions, ActivityDetection, includeStylesheet, ThemeHelper) {
23
+ "use strict";
24
+
25
+
26
+ var oThemeManager;
27
+
28
+ var maxThemeCheckCycles = 150;
29
+ var mAllLoadedLibraries = {};
30
+ var CUSTOMCSSCHECK = /\.sapUiThemeDesignerCustomCss/i;
31
+
32
+ /**
33
+ * Creates a new ThemeManager object.
34
+ *
35
+ * @class Helper class used by the UI5 Core to check whether the themes are applied correctly.
36
+ *
37
+ * It could happen that e.g. in onAfterRendering not all themes are available. In these cases the
38
+ * check waits until the CSS is applied and fires an onThemeChanged event.
39
+ *
40
+ * @extends sap.ui.base.Object
41
+ * @since 1.10.0
42
+ * @author SAP SE
43
+ * @private
44
+ * @alias sap.ui.core.theming.ThemeManager
45
+ */
46
+ var ThemeManager = EventProvider.extend("sap.ui.core.theming.ThemeManager", /** @lends sap.ui.core.theming.ThemeManager.prototype */ {
47
+
48
+ constructor : function() {
49
+ EventProvider.apply(this, arguments);
50
+ this._iCount = 0; // Prevent endless loop
51
+ this._CUSTOMID = "sap-ui-core-customcss";
52
+ this._customCSSAdded = false;
53
+ this._themeCheckedForCustom = null;
54
+ this._sFallbackTheme = null;
55
+ this._mThemeFallback = {};
56
+
57
+ setupThemes(this);
58
+ this.themeLoaded = true;
59
+ },
60
+
61
+ metadata: {
62
+ events: {
63
+ "ThemeChanged": {}
64
+ }
65
+ },
66
+
67
+ /**
68
+ * Trigger ThemeManager
69
+ *
70
+ * @private
71
+ * @ui5-restricted sap.ui.core
72
+ */
73
+ checkThemeChanged : function() {
74
+ this.reset();
75
+ delayedCheckTheme(true);
76
+ if (!this._sThemeCheckId) {
77
+ this.fireThemeChanged();
78
+ }
79
+ }
80
+
81
+ });
82
+
83
+ ThemeManager.prototype.themeLoaded = false;
84
+
85
+ /**
86
+ * Resets the internal bookkeeping
87
+ *
88
+ * @private
89
+ * @ui5-restricted sap.ui.core.Core
90
+ */
91
+ ThemeManager.prototype.reset = function() {
92
+ this.themeLoaded = false;
93
+ if (this._sThemeCheckId) {
94
+ clearTimeout(this._sThemeCheckId);
95
+ this._sThemeCheckId = null;
96
+ this._iCount = 0;
97
+ this._sFallbackTheme = null;
98
+ this._mThemeFallback = {};
99
+ }
100
+ };
101
+
102
+ function checkTheme() {
103
+ var sThemeName = Configuration.getTheme();
104
+ var sPath = oThemeManager._getThemePath("sap.ui.core", sThemeName) + "custom.css";
105
+ var bIsStandardTheme = sThemeName.indexOf("sap_") === 0 || sThemeName === "base";
106
+ var res = true;
107
+
108
+ var aFailedLibs = [];
109
+
110
+ if (oThemeManager._customCSSAdded && oThemeManager._themeCheckedForCustom === sThemeName) {
111
+ // include custom style sheet here because it has already been added using sap/ui/dom/includeStyleSheet
112
+ // hence, needs to be checked for successful inclusion, too
113
+ mAllLoadedLibraries[oThemeManager._CUSTOMID] = {};
114
+ }
115
+
116
+ function checkAndRemoveStyle(sPrefix, sLib) {
117
+ var currentRes = ThemeHelper.checkStyle(sPrefix + sLib, true);
118
+ if (currentRes) {
119
+
120
+ // removes all old stylesheets (multiple could exist if theme change was triggered
121
+ // twice in a short timeframe) once the new stylesheet has been loaded
122
+ var aOldStyles = document.querySelectorAll("link[data-sap-ui-foucmarker='" + sPrefix + sLib + "']");
123
+ if (aOldStyles.length > 0) {
124
+ for (var i = 0, l = aOldStyles.length; i < l; i++) {
125
+ aOldStyles[i].remove();
126
+ }
127
+ Log.debug("ThemeManager: Old stylesheets removed for library: " + sLib);
128
+ }
129
+
130
+ }
131
+ return currentRes;
132
+ }
133
+
134
+ function checkLib(lib) {
135
+ var sStyleId = "sap-ui-theme-" + lib;
136
+ var currentRes = checkAndRemoveStyle("sap-ui-theme-", lib);
137
+ if (currentRes && document.getElementById("sap-ui-themeskeleton-" + lib)) {
138
+ // remove also the skeleton if present in the DOM
139
+ currentRes = checkAndRemoveStyle("sap-ui-themeskeleton-", lib);
140
+ }
141
+ res = res && currentRes;
142
+ if (res) {
143
+
144
+ /* as soon as css has been loaded, look if there is a flag for custom css inclusion inside, but only
145
+ * if this has not been checked successfully before for the same theme
146
+ */
147
+ if (oThemeManager._themeCheckedForCustom != sThemeName) {
148
+ // custom css is supported for custom themes, so this check is skipped for standard themes
149
+ if (!bIsStandardTheme && checkCustom(lib)) {
150
+ // load custom css available at sap/ui/core/themename/custom.css
151
+ var sCustomCssPath = sPath;
152
+
153
+ // check for configured query parameters and add them if available
154
+ var sLibCssQueryParams = getLibraryCssQueryParams(mAllLoadedLibraries["sap.ui.core"]);
155
+ if (sLibCssQueryParams) {
156
+ sCustomCssPath += sLibCssQueryParams;
157
+ }
158
+
159
+ includeStylesheet(sCustomCssPath, oThemeManager._CUSTOMID);
160
+ oThemeManager._customCSSAdded = true;
161
+ Log.debug("ThemeManager: delivered custom CSS needs to be loaded, Theme not yet applied");
162
+ oThemeManager._themeCheckedForCustom = sThemeName;
163
+ res = false;
164
+ return false;
165
+ } else {
166
+ // remove stylesheet once the particular class is not available (e.g. after theme switch)
167
+ /*check for custom theme was not successful, so we need to make sure there are no custom style sheets attached*/
168
+ var oCustomCssLink = document.querySelector("LINK[id='" + oThemeManager._CUSTOMID + "']");
169
+ if (oCustomCssLink) {
170
+ oCustomCssLink.remove();
171
+ Log.debug("ThemeManager: Custom CSS removed");
172
+ }
173
+ oThemeManager._customCSSAdded = false;
174
+ }
175
+ }
176
+ }
177
+
178
+ // Collect all libs that failed to load and no fallback has been applied, yet.
179
+ // The fallback relies on custom theme metadata, so it is not done for standard themes
180
+ if (!bIsStandardTheme && currentRes && !oThemeManager._mThemeFallback[lib]) {
181
+ var oStyle = document.getElementById(sStyleId);
182
+ // Check for error marker (data-sap-ui-ready=false) and that there are no rules
183
+ // to be sure the stylesheet couldn't be loaded at all.
184
+ // E.g. in case an @import within the stylesheet fails, the error marker will
185
+ // also be set, but in this case no fallback should be done as there is a (broken) theme
186
+ if (oStyle && oStyle.getAttribute("data-sap-ui-ready") === "false" &&
187
+ !(oStyle.sheet && ThemeHelper.hasSheetCssRules(oStyle.sheet))
188
+ ) {
189
+ aFailedLibs.push(lib);
190
+ }
191
+ }
192
+
193
+ }
194
+
195
+ each(mAllLoadedLibraries, checkLib);
196
+
197
+ // Try to load a fallback theme for all libs that couldn't be loaded
198
+ if (aFailedLibs.length > 0) {
199
+
200
+ // Only retrieve the fallback theme once per ThemeManager cycle
201
+ if (!oThemeManager._sFallbackTheme) {
202
+ for (var sLib in mAllLoadedLibraries) {
203
+ var oThemeMetaData = ThemeHelper.getMetadata(sLib);
204
+ if (oThemeMetaData && oThemeMetaData.Extends && oThemeMetaData.Extends[0]) {
205
+ oThemeManager._sFallbackTheme = oThemeMetaData.Extends[0];
206
+ break;
207
+ }
208
+ }
209
+ }
210
+
211
+ if (oThemeManager._sFallbackTheme) {
212
+ aFailedLibs.forEach(function(lib) {
213
+ var sStyleId = "sap-ui-theme-" + lib;
214
+ var oStyle = document.getElementById(sStyleId);
215
+
216
+ Log.warning(
217
+ "ThemeManager: Custom theme '" + sThemeName + "' could not be loaded for library '" + lib + "'. " +
218
+ "Falling back to its base theme '" + oThemeManager._sFallbackTheme + "'."
219
+ );
220
+
221
+ // Change the URL to load the fallback theme
222
+ updateThemeUrl(oStyle, oThemeManager._sFallbackTheme);
223
+
224
+ // remember the lib to prevent doing the fallback multiple times
225
+ // (if the fallback also can't be loaded)
226
+ oThemeManager._mThemeFallback[lib] = true;
227
+ });
228
+
229
+ // Make sure to wait for the fallback themes to be loaded
230
+ res = false;
231
+ }
232
+ }
233
+
234
+ if (!res) {
235
+ Log.debug("ThemeManager: Theme not yet applied.");
236
+ } else {
237
+ oThemeManager._themeCheckedForCustom = sThemeName;
238
+ }
239
+ return res;
240
+ }
241
+
242
+ /* checks if a particular class is available
243
+ */
244
+ function checkCustom(lib) {
245
+
246
+ var cssFile = window.document.getElementById("sap-ui-theme-" + lib);
247
+
248
+ if (!cssFile) {
249
+ return false;
250
+ }
251
+
252
+ /*
253
+ Check if custom.css indication rule is applied to <link> element
254
+ The rule looks like this:
255
+
256
+ link[id^="sap-ui-theme-"]::after,
257
+ .sapUiThemeDesignerCustomCss {
258
+ content: '{"customcss" : true}';
259
+ }
260
+
261
+ First selector is to apply it to the <link> elements,
262
+ the second one for the Safari workaround (see below).
263
+ */
264
+ var style = window.getComputedStyle(cssFile, ':after');
265
+ var content = style ? style.getPropertyValue('content') : null;
266
+
267
+ if (!content && Device.browser.safari) {
268
+
269
+ // Safari has a bug which prevents reading properties of hidden pseudo elements
270
+ // As a workaround: Add "sapUiThemeDesignerCustomCss" class on html element
271
+ // in order to get the computed "content" value and remove it again.
272
+ var html = document.documentElement;
273
+
274
+ html.classList.add("sapUiThemeDesignerCustomCss");
275
+ content = window.getComputedStyle(html, ":after").getPropertyValue("content");
276
+ html.classList.remove("sapUiThemeDesignerCustomCss");
277
+ }
278
+
279
+ if (content && content !== "none") {
280
+ try {
281
+
282
+ // Strip surrounding quotes (single or double depending on browser)
283
+ if (content[0] === "'" || content[0] === '"') {
284
+ content = content.substring(1, content.length - 1);
285
+ }
286
+
287
+ // Cast to boolean (returns true if string equals "true", otherwise false)
288
+ return content === "true";
289
+
290
+ } catch (e) {
291
+ // parsing error
292
+ Log.error("Custom check: Error parsing JSON string for custom.css indication.", e);
293
+ }
294
+ }
295
+
296
+ //***********************************
297
+ // Fallback legacy customcss check
298
+ //***********************************
299
+
300
+ /*
301
+ * checks if a particular class is available at the beginning of the stylesheet
302
+ */
303
+
304
+ var aRules = cssFile.sheet ? ThemeHelper.safeAccessSheetCssRules(cssFile.sheet) : null;
305
+
306
+ if (!aRules || aRules.length === 0) {
307
+ Log.warning("Custom check: Failed retrieving a CSS rule from stylesheet " + lib);
308
+ return false;
309
+ }
310
+
311
+ // we should now have some rule name ==> try to match against custom check
312
+ for (var i = 0; (i < 2 && i < aRules.length) ; i++) {
313
+ if (CUSTOMCSSCHECK.test(aRules[i].selectorText)) {
314
+ return true;
315
+ }
316
+ }
317
+
318
+ return false;
319
+ }
320
+
321
+ function delayedCheckTheme(bFirst) {
322
+ oThemeManager._iCount++;
323
+
324
+ var bEmergencyExit = oThemeManager._iCount > maxThemeCheckCycles;
325
+
326
+ if (!checkTheme() && !bEmergencyExit) {
327
+ // Use dynamic delay to have a fast check for most use cases
328
+ // but not cause too much CPU usage for long running css requests
329
+ var iDelay;
330
+ if (oThemeManager._iCount <= 100) {
331
+ iDelay = 2; // 1. Initial interval
332
+ } else if (oThemeManager._iCount <= 110) {
333
+ iDelay = 500; // 2. After 100 cycles
334
+ } else {
335
+ iDelay = 1000; // 3. After another 10 cycles (about 5 seconds)
336
+ }
337
+ oThemeManager._sThemeCheckId = setTimeout(delayedCheckTheme, iDelay);
338
+ } else if (!bFirst) {
339
+ oThemeManager.reset();
340
+ oThemeManager.themeLoaded = true;
341
+ oThemeManager.fireThemeChanged();
342
+ if (bEmergencyExit) {
343
+ Log.error("ThemeManager: max. check cycles reached.");
344
+ }
345
+ } else {
346
+ oThemeManager.themeLoaded = true;
347
+ }
348
+ }
349
+
350
+ // helper to add the FOUC marker to the CSS for the given id
351
+ function fnAddFoucmarker(sLinkId) {
352
+ var oLink = document.getElementById(sLinkId);
353
+ if (oLink) {
354
+ oLink.dataset.sapUiFoucmarker = sLinkId;
355
+ }
356
+ }
357
+
358
+ /**
359
+ * Includes a library theme into the current page (if a variant is specified it
360
+ * will include the variant library theme) and ensure theme root
361
+ * @param {object} [oLibThemingInfo] to be used only by the Core
362
+ * @since 1.108
363
+ * @private
364
+ * @ui5-restricted sap.ui.core
365
+ */
366
+ ThemeManager.prototype._includeLibraryThemeAndEnsureThemeRoot = function(oLibThemingInfo) {
367
+ var sLibName = oLibThemingInfo.name;
368
+ // ensure to register correct library theme module path even when "preloadLibCss" prevents
369
+ // including the library theme as controls might use it to calculate theme-specific URLs
370
+ _ensureThemeRoot(sLibName, Configuration.getTheme());
371
+
372
+ // also ensure correct theme root for the library's base theme which might be relevant in some cases
373
+ // (e.g. IconPool which includes font files from sap.ui.core base theme)
374
+ _ensureThemeRoot(sLibName, "base");
375
+
376
+ if (Configuration.getValue('preloadLibCss').indexOf(sLibName) < 0) {
377
+ this.includeLibraryTheme(sLibName, oLibThemingInfo.variant, oLibThemingInfo);
378
+ }
379
+ };
380
+
381
+ /**
382
+ * Includes a library theme into the current page (if a variant is specified it
383
+ * will include the variant library theme)
384
+ * @param {string} sLibName the name of the UI library
385
+ * @param {string} [sVariant] the variant to include (optional)
386
+ * @param {string|object} [vQueryOrLibInfo] to be used only by the Core
387
+ * @since 1.108
388
+ * @private
389
+ * @ui5-restricted sap.ui.core
390
+ */
391
+ ThemeManager.prototype.includeLibraryTheme = function(sLibName, sVariant, vQueryOrLibInfo) {
392
+ assert(typeof sLibName === "string", "sLibName must be a string");
393
+ assert(sVariant === undefined || typeof sVariant === "string", "sVariant must be a string or undefined");
394
+ var sQuery = vQueryOrLibInfo;
395
+
396
+ if (typeof sQuery === "object") {
397
+ // check for configured query parameters and use them
398
+ sQuery = getLibraryCssQueryParams(vQueryOrLibInfo);
399
+ mAllLoadedLibraries[sLibName] = vQueryOrLibInfo;
400
+ }
401
+
402
+ /*
403
+ * by specifying a library name containing a colon (":") you can specify
404
+ * the file name of the CSS file to include (ignoring RTL)
405
+ */
406
+
407
+ // include the stylesheet for the library (except for "classic" and "legacy" lib)
408
+ if ((sLibName != "sap.ui.legacy") && (sLibName != "sap.ui.classic")) {
409
+
410
+ // no variant?
411
+ if (!sVariant) {
412
+ sVariant = "";
413
+ }
414
+ // determine CSS Variables / RTL
415
+ var sCssVars = (/^(true|x)$/i.test(Configuration.getValue('xx-cssVariables')) ? "_skeleton" : "");
416
+ var sRtl = (Configuration.getRTL() ? "-RTL" : "");
417
+
418
+ // create the library file name
419
+ var sLibFileName,
420
+ sLibId = sLibName + (sVariant.length > 0 ? "-[" + sVariant + "]" : sVariant);
421
+ if (sLibName && sLibName.indexOf(":") == -1) {
422
+ sLibFileName = "library" + sVariant + sCssVars + sRtl;
423
+ } else {
424
+ sLibFileName = sLibName.substring(sLibName.indexOf(":") + 1) + sVariant;
425
+ sLibName = sLibName.substring(0, sLibName.indexOf(":"));
426
+ }
427
+
428
+ var sLinkId = "sap-ui-theme-" + sLibId;
429
+ var sOldCssUri = document.getElementById(sLinkId) && document.getElementById(sLinkId).href;
430
+ var sCssBasePath = new URL(this._getThemePath(sLibName, this.sTheme), document.baseURI).toString();
431
+ var sCssPathAndName = sCssBasePath + sLibFileName + ".css" + (sQuery ? sQuery : "");
432
+ var sCssVariablesPathAndName = sCssBasePath + "css_variables.css" + (sQuery ? sQuery : "");
433
+ // includeStylesheet takes care of adding link tag for library only once but we need to take care to skip
434
+ // checkThemeChanged in case the link tag does not change in order to avoid fireThemeChanged
435
+ if (!(sCssPathAndName === sOldCssUri || sCssVariablesPathAndName === sOldCssUri)) {
436
+ // use the special FOUC handling for initially existing stylesheets
437
+ // to ensure that they are not just replaced when using the
438
+ // includeStyleSheet API and to be removed later
439
+ fnAddFoucmarker(sLinkId);
440
+
441
+ // include the css variables
442
+ if (/^(true|x|additional)$/i.test(Configuration.getValue('xx-cssVariables'))) {
443
+ Log.info("Including " + sCssVariablesPathAndName + " - sap.ui.core.theming.ThemeManager.includeLibraryTheme()");
444
+ includeStylesheet(sCssVariablesPathAndName, sLinkId);
445
+ // include the skeleton css next to the css variables
446
+ sLinkId = "sap-ui-themeskeleton-" + sLibId;
447
+ fnAddFoucmarker(sLinkId);
448
+ }
449
+
450
+ // log and include
451
+ Log.info("Including " + sCssPathAndName + " - sap.ui.core.theming.ThemeManager.includeLibraryTheme()");
452
+ includeStylesheet(sCssPathAndName, sLinkId);
453
+
454
+ // if parameters have been used, update them with the new style sheet
455
+ var Parameters = sap.ui.require("sap/ui/core/theming/Parameters");
456
+ if (Parameters) {
457
+ Parameters._addLibraryTheme(sLibId);
458
+ }
459
+ this.checkThemeChanged();
460
+ }
461
+ }
462
+ };
463
+
464
+ /**
465
+ * Returns the URL of the folder in which the CSS file for the given theme and the given library is located.
466
+ *
467
+ * @param {string} sLibName Library name (dot separated)
468
+ * @param {string} sThemeName Theme name
469
+ * @returns {string} module path URL (ends with a slash)
470
+ * @since 1.108
471
+ * @private
472
+ * @ui5-restricted sap.ui.core,sap.ui.support.supportRules.report.DataCollector
473
+ */
474
+ ThemeManager.prototype._getThemePath = function(sLibName, sThemeName) {
475
+
476
+ // make sure to register correct theme module path in case themeRoots are defined
477
+ _ensureThemeRoot(sLibName, sThemeName);
478
+
479
+ // use the library location as theme location
480
+ return sap.ui.require.toUrl((sLibName + ".themes." + sThemeName).replace(/\./g, "/") + "/");
481
+ };
482
+
483
+ /**
484
+ * Makes sure to register the correct module path for the given library and theme
485
+ * in case a themeRoot has been defined.
486
+ *
487
+ * @param {string} sLibName Library name (dot separated)
488
+ * @param {string} sThemeName Theme name
489
+ * @private
490
+ */
491
+ function _ensureThemeRoot(sLibName, sThemeName) {
492
+ if (oThemeManager._mThemeRoots) {
493
+ var path = oThemeManager._mThemeRoots[sThemeName + " " + sLibName] || oThemeManager._mThemeRoots[sThemeName];
494
+ // check whether for this combination (theme+lib) a URL is registered or for this theme a default location is registered
495
+ if (path) {
496
+ path = path + sLibName.replace(/\./g, "/") + "/themes/" + sThemeName + "/";
497
+ LoaderExtensions.registerResourcePath((sLibName + ".themes." + sThemeName).replace(/\./g, "/"), path);
498
+ }
499
+ }
500
+ }
501
+
502
+ /**
503
+ * Defines the root directory from below which UI5 should load the theme with the given name.
504
+ * Optionally allows restricting the setting to parts of a theme covering specific control libraries.
505
+ *
506
+ * Example:
507
+ * <pre>
508
+ * sap.ui.getCore().setThemeRoot("my_theme", "https://mythemeserver.com/allThemes");
509
+ * sap.ui.getCore().applyTheme("my_theme");
510
+ * </pre>
511
+ *
512
+ * will cause the following file to be loaded (assuming that the bootstrap is configured to load
513
+ * libraries <code>sap.m</code> and <code>sap.ui.layout</code>):
514
+ * <pre>
515
+ * https://mythemeserver.com/allThemes/sap/ui/core/themes/my_theme/library.css
516
+ * https://mythemeserver.com/allThemes/sap/ui/layout/themes/my_theme/library.css
517
+ * https://mythemeserver.com/allThemes/sap/m/themes/my_theme/library.css
518
+ * </pre>
519
+ *
520
+ * If parts of the theme are at different locations (e.g. because you provide a standard theme
521
+ * like "sap_belize" for a custom control library and this self-made part of the standard theme is at a
522
+ * different location than the UI5 resources), you can also specify for which control libraries the setting
523
+ * should be used, by giving an array with the names of the respective control libraries as second parameter:
524
+ * <pre>
525
+ * sap.ui.getCore().setThemeRoot("sap_belize", ["my.own.library"], "https://mythemeserver.com/allThemes");
526
+ * </pre>
527
+ *
528
+ * This will cause the Belize theme to be loaded from the UI5 location for all standard libraries.
529
+ * Resources for styling the <code>my.own.library</code> controls will be loaded from the configured
530
+ * location:
531
+ * <pre>
532
+ * https://openui5.hana.ondemand.com/resources/sap/ui/core/themes/sap_belize/library.css
533
+ * https://openui5.hana.ondemand.com/resources/sap/ui/layout/themes/sap_belize/library.css
534
+ * https://openui5.hana.ondemand.com/resources/sap/m/themes/sap_belize/library.css
535
+ * https://mythemeserver.com/allThemes/my/own/library/themes/sap_belize/library.css
536
+ * </pre>
537
+ *
538
+ * If the custom theme should be loaded initially (via bootstrap attribute), the <code>themeRoots</code>
539
+ * property of the <code>window["sap-ui-config"]</code> object must be used instead of calling
540
+ * <code>sap.ui.getCore().setThemeRoot(...)</code> in order to configure the theme location early enough.
541
+ *
542
+ * @param {string} sThemeName Name of the theme for which to configure the location
543
+ * @param {string[]} [aLibraryNames] Optional library names to which the configuration should be restricted
544
+ * @param {string} sThemeBaseUrl Base URL below which the CSS file(s) will be loaded from
545
+ * @param {boolean} [bForceUpdate=false] Force updating URLs of currently loaded theme
546
+ * @since 1.108
547
+ * @private
548
+ * @ui5-restricted sap.ui.core.Core
549
+ */
550
+ ThemeManager.prototype.setThemeRoot = function(sThemeName, aLibraryNames, sThemeBaseUrl, bForceUpdate) {
551
+ assert(typeof sThemeName === "string", "sThemeName must be a string");
552
+ assert((Array.isArray(aLibraryNames) && typeof sThemeBaseUrl === "string") || (typeof aLibraryNames === "string" && sThemeBaseUrl === undefined), "either the second parameter must be a string (and the third is undefined), or it must be an array and the third parameter is a string");
553
+
554
+ if (!this._mThemeRoots) {
555
+ this._mThemeRoots = {};
556
+ }
557
+
558
+ // normalize parameters
559
+ if (typeof aLibraryNames === "string") {
560
+ bForceUpdate = sThemeBaseUrl;
561
+ sThemeBaseUrl = aLibraryNames;
562
+ aLibraryNames = undefined;
563
+ }
564
+ sThemeBaseUrl = sThemeBaseUrl + (sThemeBaseUrl.slice( -1) == "/" ? "" : "/");
565
+
566
+ if (aLibraryNames) {
567
+ // registration of URL for several libraries
568
+ for (var i = 0; i < aLibraryNames.length; i++) {
569
+ var lib = aLibraryNames[i];
570
+ this._mThemeRoots[sThemeName + " " + lib] = sThemeBaseUrl;
571
+ }
572
+
573
+ } else {
574
+ // registration of theme default base URL
575
+ this._mThemeRoots[sThemeName] = sThemeBaseUrl;
576
+ }
577
+
578
+ // Update theme urls when theme roots of currently loaded theme have changed
579
+ if (bForceUpdate && sThemeName === this.sTheme) {
580
+ this._updateThemeUrls(this.sTheme);
581
+ }
582
+ };
583
+
584
+ /**
585
+ * Modify style sheet URLs to point to the given theme, using the current RTL mode
586
+ *
587
+ * @param {string} sThemeName The name of the theme to update
588
+ * @param {boolean} bSuppressFOUC If FOUC-Marker should be added or not
589
+ * @since 1.108
590
+ * @private
591
+ * @ui5-restricted sap.ui.core.Core
592
+ */
593
+ ThemeManager.prototype._updateThemeUrls = function(sThemeName, bSuppressFOUC) {
594
+ // select "our" stylesheets
595
+ var oQueryResult = document.querySelectorAll("link[id^=sap-ui-theme-],link[id^=sap-ui-themeskeleton-]");
596
+
597
+ Array.prototype.forEach.call(oQueryResult, function(oHTMLElement) {
598
+ updateThemeUrl(oHTMLElement, sThemeName, bSuppressFOUC);
599
+ });
600
+
601
+ };
602
+
603
+ // this function is also used by "sap.ui.core.theming.ThemeManager" to load a fallback theme for a single library
604
+ function updateThemeUrl(oLink, sThemeName, bSuppressFOUC) {
605
+ var sLibName,
606
+ iQueryIndex = oLink.href.search(/[?#]/),
607
+ sLibFileName,
608
+ sQuery,
609
+ sStandardLibFilePrefix = "library",
610
+ sRTL = Configuration.getRTL() ? "-RTL" : "",
611
+ sHref,
612
+ pos;
613
+
614
+ // derive lib name from id via regex
615
+ var mLinkId = /^sap-ui-theme(?:skeleton)?-(.*)$/i.exec(oLink.id);
616
+ if (Array.isArray(mLinkId)) {
617
+ sLibName = mLinkId[1];
618
+ } else {
619
+ // fallback to legacy logic
620
+ sLibName = oLink.id.slice(13); // length of "sap-ui-theme-"
621
+ }
622
+
623
+ if (iQueryIndex > -1) {
624
+ // Split href on query and/or fragment to check for the standard lib file prefix
625
+ sLibFileName = oLink.href.substring(0, iQueryIndex);
626
+ sQuery = oLink.href.substring(iQueryIndex);
627
+ } else {
628
+ sLibFileName = oLink.href;
629
+ sQuery = "";
630
+ }
631
+
632
+ // Get basename of stylesheet (e.g. "library.css")
633
+ sLibFileName = sLibFileName.substring(sLibFileName.lastIndexOf("/") + 1);
634
+
635
+ // handle 'variants'
636
+ if ((pos = sLibName.indexOf("-[")) > 0) { // assumes that "-[" does not occur as part of a library name
637
+ sStandardLibFilePrefix += sLibName.slice(pos + 2, -1); // 2=length of "-]"
638
+ sLibName = sLibName.slice(0, pos);
639
+ }
640
+
641
+ // try to distinguish "our" library css from custom css included with the ':' notation in includeLibraryTheme
642
+ if ( sLibFileName === (sStandardLibFilePrefix + ".css") || sLibFileName === (sStandardLibFilePrefix + "-RTL.css") ) {
643
+ sLibFileName = sStandardLibFilePrefix + sRTL + ".css";
644
+ }
645
+
646
+ sHref = oThemeManager._getThemePath(sLibName, sThemeName) + sLibFileName + sQuery;
647
+ if ( sHref != oLink.href ) {
648
+ // sap/ui/dom/includeStylesheet has a special FOUC handling
649
+ // which is activated once the attribute data-sap-ui-foucmarker is
650
+ // present on the link to be replaced (usage of the Promise
651
+ // API is not sufficient as it will change the sync behavior)
652
+ if (bSuppressFOUC) {
653
+ oLink.dataset.sapUiFoucmarker = oLink.id;
654
+ }
655
+ // Replace the current <link> tag with a new one.
656
+ // Changing "oLink.href" would also trigger loading the new stylesheet but
657
+ // the load/error handlers would not get called which causes issues with the ThemeManager
658
+ // as the "data-sap-ui-ready" attribute won't be set.
659
+ includeStylesheet(sHref, oLink.id);
660
+ }
661
+ }
662
+
663
+ /**
664
+ * Applies the theme with the given name (by loading the respective style sheets, which does not disrupt the application).
665
+ *
666
+ * By default, the theme files are expected to be located at path relative to the respective control library ([libraryLocation]/themes/[themeName]).
667
+ * Different locations can be configured by using the method setThemePath() or by using the second parameter "sThemeBaseUrl" of applyTheme().
668
+ * Usage of this second parameter is a shorthand for setThemePath and internally calls setThemePath, so the theme location is then known.
669
+ *
670
+ * sThemeBaseUrl is a single URL to specify the default location of all theme files. This URL is the base folder below which the control library folders
671
+ * are located. E.g. if the CSS files are not located relative to the root location of UI5, but instead they are at locations like
672
+ * http://my.server/myapp/resources/sap/ui/core/themes/my_theme/library.css
673
+ * then the URL that needs to be given is:
674
+ * http://my.server/myapp/resources
675
+ * All theme resources are then loaded from below this folder - except if for a certain library a different location has been registered.
676
+ *
677
+ * If the theme resources are not all either below this base location or with their respective libraries, then setThemePath must be
678
+ * used to configure individual locations.
679
+ *
680
+ * @param {string} sThemeName The name of the theme to be loaded
681
+ * @param {string} [sThemeBaseUrl] The (optional) base location of the theme
682
+ * @param {boolean} [bForce] Apply theme even if theme hasn't changed.
683
+ * <code>sap.ui.core.Core</code> does a lazy require of
684
+ * ThemeManager. Loading could be already done, but no change
685
+ * was fired.
686
+ * @since 1.108
687
+ * @private
688
+ */
689
+ ThemeManager.prototype.applyTheme = function(sThemeName, sThemeBaseUrl, bForce) {
690
+ assert(typeof sThemeName === "string", "sThemeName must be a string");
691
+ assert(typeof sThemeBaseUrl === "string" || typeof sThemeBaseUrl === "undefined", "sThemeBaseUrl must be a string or undefined");
692
+
693
+ sThemeName = Configuration.normalizeTheme(sThemeName, sThemeBaseUrl);
694
+
695
+ if (sThemeBaseUrl) {
696
+ this.setThemeRoot(sThemeName, sThemeBaseUrl);
697
+ }
698
+
699
+ // only apply the theme if it is different from the active one
700
+ if ((sThemeName && this.sTheme != sThemeName) || bForce) {
701
+ var sCurrentTheme = this.sTheme;
702
+ var html = document.documentElement;
703
+ this._updateThemeUrls(sThemeName, /* bSuppressFOUC */ true);
704
+ this.sTheme = sThemeName;
705
+ Configuration.setTheme(sThemeName);
706
+
707
+ // modify the <html> tag's CSS class with the theme name
708
+ html.classList.remove("sapUiTheme-" + sCurrentTheme);
709
+ html.classList.add("sapUiTheme-" + sThemeName);
710
+
711
+ // notify the listeners
712
+ this.checkThemeChanged();
713
+ }
714
+ };
715
+
716
+ /**
717
+ * Returns a string containing query parameters for theme specific files.
718
+ *
719
+ * Used in Core#initLibrary and ThemeManager#checkStyle.
720
+ *
721
+ * @param {object} oLibInfo Library info object (containing a "version" property)
722
+ * @returns {string|undefined} query parameters or undefined if "versionedLibCss" config is "false"
723
+ * @private
724
+ */
725
+ function getLibraryCssQueryParams(oLibInfo) {
726
+ var sQuery;
727
+ if (Configuration.getValue("versionedLibCss") && oLibInfo) {
728
+ sQuery = "?version=" + oLibInfo.version;
729
+
730
+ // distribution version may not be available (will be loaded in Core constructor syncpoint2)
731
+ if (Global.versioninfo) {
732
+ sQuery += "&sap-ui-dist-version=" + Global.versioninfo.version;
733
+ }
734
+ }
735
+ return sQuery;
736
+ }
737
+
738
+ /**
739
+ * Initializes the window "sap-ui-config" property, sets theme roots, initializes sTheme, sets theme CSS classes
740
+ * @private
741
+ */
742
+ function setupThemes(oThemeManager) {
743
+ var mThemeRoots = Configuration.getValue("themeRoots");
744
+ // read themeRoots configuration
745
+ if (mThemeRoots) {
746
+ for (var themeName in mThemeRoots) {
747
+ var themeRoot = mThemeRoots[themeName];
748
+ if (typeof themeRoot === "string") {
749
+ oThemeManager.setThemeRoot(themeName, themeRoot);
750
+ } else {
751
+ for (var lib in themeRoot) {
752
+ if (lib.length > 0) {
753
+ oThemeManager.setThemeRoot(themeName, [lib], themeRoot[lib]);
754
+ } else {
755
+ oThemeManager.setThemeRoot(themeName, themeRoot[lib]);
756
+ }
757
+ }
758
+ }
759
+ }
760
+ }
761
+
762
+ // set CSS class for the theme name
763
+ oThemeManager.sTheme = Configuration.getTheme();
764
+ document.documentElement.classList.add("sapUiTheme-" + oThemeManager.sTheme);
765
+ Log.info("Declared theme " + oThemeManager.sTheme,null);
766
+ }
767
+
768
+ /**
769
+ * Notify content density changes
770
+ *
771
+ * @since 1.108
772
+ * @private
773
+ * @ui5-restricted sap.ui.core.Core
774
+ */
775
+ ThemeManager.prototype.notifyContentDensityChanged = function () {
776
+ this.fireThemeChanged();
777
+ };
778
+
779
+ /**
780
+ * Notify theme change
781
+ *
782
+ * @param {object} oParameters The event parameters
783
+ * @since 1.108
784
+ * @private
785
+ * @ui5-restricted sap.ui.core.Core
786
+ */
787
+ ThemeManager.prototype.fireThemeChanged = function (oParameters) {
788
+ // special hook for resetting theming parameters before the controls get
789
+ // notified (lightweight coupling to static Parameters module)
790
+ var ThemeParameters = sap.ui.require("sap/ui/core/theming/Parameters");
791
+ if (ThemeParameters) {
792
+ ThemeParameters._reset(/* bOnlyWhenNecessary= */ true);
793
+ }
794
+
795
+ oParameters = oParameters || {};
796
+ // set the current theme name as default if omitted
797
+ if (!oParameters.theme) {
798
+ oParameters.theme = Configuration.getTheme();
799
+ }
800
+
801
+ // notify all elements/controls via a pseudo browser event
802
+ var sEventId = "ThemeChanged";
803
+ var oEvent = jQuery.Event(sEventId);
804
+ oEvent.theme = oParameters.theme;
805
+ Element.registry.forEach(function(oElement) {
806
+ oElement._handleEvent(oEvent);
807
+ });
808
+
809
+ ActivityDetection.refresh();
810
+ this.fireEvent(sEventId, oParameters);
811
+ };
812
+
813
+ oThemeManager = new ThemeManager();
814
+
815
+ return oThemeManager;
816
+
817
+ });