@openui5/sap.ui.core 1.139.0 → 1.140.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.
- package/THIRDPARTY.txt +1 -1
- package/package.json +1 -1
- package/src/jquery.sap.global.js +1 -1
- package/src/jquery.sap.mobile.js +0 -8
- package/src/jquery.sap.properties.js +1 -1
- package/src/jquery.sap.resources.js +1 -1
- package/src/jquery.sap.script.js +1 -1
- package/src/jquery.sap.storage.js +3 -3
- package/src/sap/base/Event.js +1 -1
- package/src/sap/base/Eventing.js +1 -1
- package/src/sap/base/config.js +1 -1
- package/src/sap/base/i18n/LanguageTag.js +1 -1
- package/src/sap/base/i18n/date/TimezoneUtils.js +1 -1
- package/src/sap/base/security/URLListValidator.js +7 -3
- package/src/sap/base/util/restricted/_CancelablePromise.js +1 -1
- package/src/sap/base/util/restricted/_castArray.js +1 -1
- package/src/sap/base/util/restricted/_compact.js +1 -1
- package/src/sap/base/util/restricted/_curry.js +1 -1
- package/src/sap/base/util/restricted/_debounce.js +1 -1
- package/src/sap/base/util/restricted/_difference.js +1 -1
- package/src/sap/base/util/restricted/_differenceBy.js +1 -1
- package/src/sap/base/util/restricted/_differenceWith.js +1 -1
- package/src/sap/base/util/restricted/_flatMap.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDeep.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDepth.js +1 -1
- package/src/sap/base/util/restricted/_flatten.js +1 -1
- package/src/sap/base/util/restricted/_flattenDeep.js +1 -1
- package/src/sap/base/util/restricted/_flattenDepth.js +1 -1
- package/src/sap/base/util/restricted/_intersection.js +1 -1
- package/src/sap/base/util/restricted/_intersectionBy.js +1 -1
- package/src/sap/base/util/restricted/_intersectionWith.js +1 -1
- package/src/sap/base/util/restricted/_isEqual.js +1 -1
- package/src/sap/base/util/restricted/_isEqualWith.js +1 -1
- package/src/sap/base/util/restricted/_isNil.js +1 -1
- package/src/sap/base/util/restricted/_max.js +1 -1
- package/src/sap/base/util/restricted/_merge.js +1 -1
- package/src/sap/base/util/restricted/_mergeWith.js +1 -1
- package/src/sap/base/util/restricted/_min.js +1 -1
- package/src/sap/base/util/restricted/_omit.js +1 -1
- package/src/sap/base/util/restricted/_pick.js +1 -1
- package/src/sap/base/util/restricted/_pickBy.js +1 -1
- package/src/sap/base/util/restricted/_throttle.js +1 -1
- package/src/sap/base/util/restricted/_toArray.js +1 -1
- package/src/sap/base/util/restricted/_union.js +1 -1
- package/src/sap/base/util/restricted/_unionBy.js +1 -1
- package/src/sap/base/util/restricted/_unionWith.js +1 -1
- package/src/sap/base/util/restricted/_uniq.js +1 -1
- package/src/sap/base/util/restricted/_uniqBy.js +1 -1
- package/src/sap/base/util/restricted/_uniqWith.js +1 -1
- package/src/sap/base/util/restricted/_without.js +1 -1
- package/src/sap/base/util/restricted/_xor.js +1 -1
- package/src/sap/base/util/restricted/_xorBy.js +1 -1
- package/src/sap/base/util/restricted/_xorWith.js +1 -1
- package/src/sap/base/util/restricted/_zipObject.js +1 -1
- package/src/sap/base/util/restricted/_zipObjectDeep.js +1 -1
- package/src/sap/ui/Device.js +3 -3
- package/src/sap/ui/Global.js +3 -3
- package/src/sap/ui/base/BindingParser.js +1 -1
- package/src/sap/ui/base/Event.js +1 -1
- package/src/sap/ui/base/EventProvider.js +1 -1
- package/src/sap/ui/base/Interface.js +1 -1
- package/src/sap/ui/base/ManagedObject.js +1 -1
- package/src/sap/ui/base/ManagedObjectMetadata.js +1 -1
- package/src/sap/ui/base/Metadata.js +1 -1
- package/src/sap/ui/base/Object.js +1 -1
- package/src/sap/ui/base/ObjectPool.js +1 -1
- package/src/sap/ui/core/.library +2 -2
- package/src/sap/ui/core/BusyIndicator.js +1 -1
- package/src/sap/ui/core/Component.js +1 -1
- package/src/sap/ui/core/ComponentContainer.js +1 -1
- package/src/sap/ui/core/ComponentMetadata.js +1 -1
- package/src/sap/ui/core/ComponentSupport.js +1 -1
- package/src/sap/ui/core/Configuration.js +1 -1
- package/src/sap/ui/core/Control.js +1 -1
- package/src/sap/ui/core/Core.js +2 -11
- package/src/sap/ui/core/CustomData.js +1 -1
- package/src/sap/ui/core/DeclarativeSupport.js +1 -1
- package/src/sap/ui/core/Element.js +1 -1
- package/src/sap/ui/core/ElementMetadata.js +1 -1
- package/src/sap/ui/core/EnabledPropagator.js +1 -1
- package/src/sap/ui/core/EventBus.js +1 -1
- package/src/sap/ui/core/Fragment.js +1 -1
- package/src/sap/ui/core/HTML.js +1 -1
- package/src/sap/ui/core/History.js +1 -1
- package/src/sap/ui/core/Icon.js +1 -1
- package/src/sap/ui/core/IndicationColorSupport.js +1 -1
- package/src/sap/ui/core/IntervalTrigger.js +1 -1
- package/src/sap/ui/core/InvisibleMessage.js +1 -1
- package/src/sap/ui/core/InvisibleRenderer.js +1 -1
- package/src/sap/ui/core/InvisibleText.js +1 -1
- package/src/sap/ui/core/Item.js +1 -1
- package/src/sap/ui/core/LabelEnablement.js +1 -1
- package/src/sap/ui/core/LayoutData.js +1 -1
- package/src/sap/ui/core/Lib.js +15 -108
- package/src/sap/ui/core/ListItem.js +1 -1
- package/src/sap/ui/core/LocalBusyIndicator.js +1 -1
- package/src/sap/ui/core/Locale.js +1 -1
- package/src/sap/ui/core/LocaleData.js +1 -1
- package/src/sap/ui/core/Manifest.js +1 -1
- package/src/sap/ui/core/Message.js +1 -1
- package/src/sap/ui/core/RenderManager.js +1 -1
- package/src/sap/ui/core/Renderer.js +1 -1
- package/src/sap/ui/core/ResizeHandler.js +1 -1
- package/src/sap/ui/core/ScrollBar.js +1 -1
- package/src/sap/ui/core/SeparatorItem.js +1 -1
- package/src/sap/ui/core/Theming.js +145 -76
- package/src/sap/ui/core/Title.js +1 -1
- package/src/sap/ui/core/TooltipBase.js +1 -1
- package/src/sap/ui/core/UIArea.js +1 -1
- package/src/sap/ui/core/UIComponent.js +1 -1
- package/src/sap/ui/core/UIComponentMetadata.js +1 -1
- package/src/sap/ui/core/ValueStateSupport.js +1 -1
- package/src/sap/ui/core/VariantLayoutData.js +1 -1
- package/src/sap/ui/core/XMLComposite.js +1 -1
- package/src/sap/ui/core/XMLCompositeMetadata.js +1 -1
- package/src/sap/ui/core/XMLTemplateProcessor.js +1 -1
- package/src/sap/ui/core/date/UI5Date.js +1 -1
- package/src/sap/ui/core/delegate/ItemNavigation.js +1 -1
- package/src/sap/ui/core/delegate/ScrollEnablement.js +1 -1
- package/src/sap/ui/core/dnd/DragDropBase.js +1 -1
- package/src/sap/ui/core/dnd/DragDropInfo.js +1 -1
- package/src/sap/ui/core/dnd/DragInfo.js +1 -1
- package/src/sap/ui/core/dnd/DropInfo.js +1 -1
- package/src/sap/ui/core/format/FormatUtils.js +1 -1
- package/src/sap/ui/core/format/NumberFormat.js +1 -1
- package/src/sap/ui/core/format/TimezoneUtil.js +1 -1
- package/src/sap/ui/core/getCompatibilityVersion.js +1 -1
- package/src/sap/ui/core/hyphenation/Hyphenation.js +1 -1
- package/src/sap/ui/core/library.js +3 -3
- package/src/sap/ui/core/message/ControlMessageProcessor.js +1 -1
- package/src/sap/ui/core/message/Message.js +1 -1
- package/src/sap/ui/core/message/MessageManager.js +1 -1
- package/src/sap/ui/core/message/MessageParser.js +1 -1
- package/src/sap/ui/core/message/MessageProcessor.js +1 -1
- package/src/sap/ui/core/messagebundle_ar.properties +26 -11
- package/src/sap/ui/core/messagebundle_bg.properties +21 -6
- package/src/sap/ui/core/messagebundle_ca.properties +24 -9
- package/src/sap/ui/core/messagebundle_cnr.properties +23 -8
- package/src/sap/ui/core/messagebundle_cs.properties +24 -9
- package/src/sap/ui/core/messagebundle_cy.properties +24 -9
- package/src/sap/ui/core/messagebundle_da.properties +21 -6
- package/src/sap/ui/core/messagebundle_de.properties +16 -1
- package/src/sap/ui/core/messagebundle_el.properties +26 -11
- package/src/sap/ui/core/messagebundle_en.properties +24 -9
- package/src/sap/ui/core/messagebundle_en_GB.properties +24 -9
- package/src/sap/ui/core/messagebundle_en_US_saprigi.properties +24 -9
- package/src/sap/ui/core/messagebundle_es.properties +21 -6
- package/src/sap/ui/core/messagebundle_es_MX.properties +24 -9
- package/src/sap/ui/core/messagebundle_et.properties +31 -16
- package/src/sap/ui/core/messagebundle_fi.properties +20 -5
- package/src/sap/ui/core/messagebundle_fr.properties +22 -7
- package/src/sap/ui/core/messagebundle_fr_CA.properties +20 -5
- package/src/sap/ui/core/messagebundle_hi.properties +24 -9
- package/src/sap/ui/core/messagebundle_hr.properties +20 -5
- package/src/sap/ui/core/messagebundle_hu.properties +23 -8
- package/src/sap/ui/core/messagebundle_id.properties +20 -5
- package/src/sap/ui/core/messagebundle_it.properties +23 -8
- package/src/sap/ui/core/messagebundle_iw.properties +21 -6
- package/src/sap/ui/core/messagebundle_ja.properties +19 -4
- package/src/sap/ui/core/messagebundle_kk.properties +22 -7
- package/src/sap/ui/core/messagebundle_ko.properties +20 -5
- package/src/sap/ui/core/messagebundle_lt.properties +20 -5
- package/src/sap/ui/core/messagebundle_lv.properties +20 -5
- package/src/sap/ui/core/messagebundle_mk.properties +25 -10
- package/src/sap/ui/core/messagebundle_ms.properties +24 -9
- package/src/sap/ui/core/messagebundle_nl.properties +22 -7
- package/src/sap/ui/core/messagebundle_no.properties +22 -7
- package/src/sap/ui/core/messagebundle_pl.properties +19 -4
- package/src/sap/ui/core/messagebundle_pt.properties +18 -3
- package/src/sap/ui/core/messagebundle_pt_PT.properties +18 -3
- package/src/sap/ui/core/messagebundle_ro.properties +22 -7
- package/src/sap/ui/core/messagebundle_ru.properties +19 -4
- package/src/sap/ui/core/messagebundle_sh.properties +23 -8
- package/src/sap/ui/core/messagebundle_sk.properties +23 -8
- package/src/sap/ui/core/messagebundle_sl.properties +20 -5
- package/src/sap/ui/core/messagebundle_sr.properties +23 -8
- package/src/sap/ui/core/messagebundle_sv.properties +23 -8
- package/src/sap/ui/core/messagebundle_th.properties +20 -5
- package/src/sap/ui/core/messagebundle_tr.properties +20 -5
- package/src/sap/ui/core/messagebundle_uk.properties +22 -7
- package/src/sap/ui/core/messagebundle_vi.properties +18 -3
- package/src/sap/ui/core/messagebundle_zh_CN.properties +24 -9
- package/src/sap/ui/core/messagebundle_zh_TW.properties +20 -5
- package/src/sap/ui/core/mvc/HTMLView.js +1 -1
- package/src/sap/ui/core/mvc/JSONView.js +1 -1
- package/src/sap/ui/core/mvc/JSView.js +1 -1
- package/src/sap/ui/core/mvc/TemplateView.js +1 -1
- package/src/sap/ui/core/mvc/View.js +1 -1
- package/src/sap/ui/core/mvc/XMLView.js +1 -1
- package/src/sap/ui/core/plugin/DeclarativeSupport.js +1 -1
- package/src/sap/ui/core/plugin/TemplatingSupport.js +1 -1
- package/src/sap/ui/core/postmessage/Bus.js +1 -1
- package/src/sap/ui/core/postmessage/confirmationDialog.js +1 -1
- package/src/sap/ui/core/routing/Route.js +1 -1
- package/src/sap/ui/core/routing/Router.js +19 -1
- package/src/sap/ui/core/search/OpenSearchProvider.js +1 -1
- package/src/sap/ui/core/search/SearchProvider.js +1 -1
- package/src/sap/ui/core/service/Service.js +1 -1
- package/src/sap/ui/core/service/ServiceFactory.js +1 -1
- package/src/sap/ui/core/service/ServiceFactoryRegistry.js +1 -1
- package/src/sap/ui/core/support/Plugin.js +1 -1
- package/src/sap/ui/core/support/Support.js +1 -1
- package/src/sap/ui/core/support/plugins/ControlTree.js +1 -1
- package/src/sap/ui/core/support/plugins/Interaction.js +1 -1
- package/src/sap/ui/core/support/plugins/LocalStorage.js +1 -1
- package/src/sap/ui/core/support/plugins/Performance.js +1 -1
- package/src/sap/ui/core/support/plugins/Selector.js +1 -1
- package/src/sap/ui/core/support/plugins/TechInfo.js +1 -1
- package/src/sap/ui/core/support/plugins/Trace.js +1 -1
- package/src/sap/ui/core/support/plugins/ViewInfo.js +1 -1
- package/src/sap/ui/core/themes/base/base.less +20 -20
- package/src/sap/ui/core/themes/base/shared.less +4 -1
- package/src/sap/ui/core/themes/base/skeleton.less +3 -3
- package/src/sap/ui/core/theming/Parameters.js +717 -755
- package/src/sap/ui/core/theming/ThemeHelper.js +0 -77
- package/src/sap/ui/core/theming/ThemeManager.js +535 -526
- package/src/sap/ui/core/tmpl/DOMAttribute.js +1 -1
- package/src/sap/ui/core/tmpl/DOMElement.js +1 -1
- package/src/sap/ui/core/tmpl/HandlebarsTemplate.js +1 -1
- package/src/sap/ui/core/tmpl/Template.js +1 -1
- package/src/sap/ui/core/tmpl/TemplateControl.js +1 -1
- package/src/sap/ui/core/util/AsyncHintsHelper.js +1 -1
- package/src/sap/ui/core/util/Export.js +1 -1
- package/src/sap/ui/core/util/ExportCell.js +1 -1
- package/src/sap/ui/core/util/ExportColumn.js +1 -1
- package/src/sap/ui/core/util/ExportRow.js +1 -1
- package/src/sap/ui/core/util/ExportType.js +1 -1
- package/src/sap/ui/core/util/ExportTypeCSV.js +1 -1
- package/src/sap/ui/core/util/File.js +1 -1
- package/src/sap/ui/core/util/LibraryInfo.js +1 -1
- package/src/sap/ui/core/util/MockServer.js +1 -1
- package/src/sap/ui/core/util/PasteHelper.js +1 -1
- package/src/sap/ui/core/util/serializer/HTMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/Serializer.js +1 -1
- package/src/sap/ui/core/util/serializer/ViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/XMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/Delegate.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/HTML.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/XML.js +1 -1
- package/src/sap/ui/core/webc/WebComponent.js +93 -45
- package/src/sap/ui/core/webc/WebComponentMetadata.js +40 -6
- package/src/sap/ui/core/ws/ReadyState.js +1 -1
- package/src/sap/ui/core/ws/SapPcpWebSocket.js +1 -1
- package/src/sap/ui/core/ws/WebSocket.js +1 -1
- package/src/sap/ui/debug/ControlTree.js +1 -1
- package/src/sap/ui/debug/DebugEnv.js +1 -1
- package/src/sap/ui/debug/PropertyList.js +1 -1
- package/src/sap/ui/dom/includeStylesheet.js +4 -1
- package/src/sap/ui/model/ClientModel.js +1 -1
- package/src/sap/ui/model/CompositeDataState.js +1 -1
- package/src/sap/ui/model/CompositeType.js +1 -1
- package/src/sap/ui/model/DataState.js +1 -1
- package/src/sap/ui/model/MetaModel.js +1 -1
- package/src/sap/ui/model/Model.js +7 -7
- package/src/sap/ui/model/SelectionModel.js +1 -1
- package/src/sap/ui/model/SimpleType.js +1 -1
- package/src/sap/ui/model/TreeAutoExpandMode.js +1 -1
- package/src/sap/ui/model/Type.js +1 -1
- package/src/sap/ui/model/json/JSONModel.js +1 -1
- package/src/sap/ui/model/json/TypedJSONContext.js +16 -0
- package/src/sap/ui/model/json/TypedJSONModel.js +16 -0
- package/src/sap/ui/model/message/MessageModel.js +1 -1
- package/src/sap/ui/model/odata/ODataAnnotations.js +1 -1
- package/src/sap/ui/model/odata/ODataMessageParser.js +1 -1
- package/src/sap/ui/model/odata/ODataMetaModel.js +1 -1
- package/src/sap/ui/model/odata/ODataMetadata.js +4 -4
- package/src/sap/ui/model/odata/ODataModel.js +1 -1
- package/src/sap/ui/model/odata/ODataTreeBindingFlat.js +9 -8
- package/src/sap/ui/model/odata/_AnnotationHelperExpression.js +2 -2
- package/src/sap/ui/model/odata/type/Boolean.js +1 -1
- package/src/sap/ui/model/odata/type/Byte.js +1 -1
- package/src/sap/ui/model/odata/type/Currency.js +1 -1
- package/src/sap/ui/model/odata/type/Date.js +1 -1
- package/src/sap/ui/model/odata/type/DateTime.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeBase.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeOffset.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeWithTimezone.js +1 -1
- package/src/sap/ui/model/odata/type/Decimal.js +1 -1
- package/src/sap/ui/model/odata/type/Double.js +1 -1
- package/src/sap/ui/model/odata/type/Guid.js +1 -1
- package/src/sap/ui/model/odata/type/Int.js +1 -1
- package/src/sap/ui/model/odata/type/Int16.js +1 -1
- package/src/sap/ui/model/odata/type/Int32.js +1 -1
- package/src/sap/ui/model/odata/type/Int64.js +1 -1
- package/src/sap/ui/model/odata/type/ODataType.js +1 -1
- package/src/sap/ui/model/odata/type/Raw.js +1 -1
- package/src/sap/ui/model/odata/type/SByte.js +1 -1
- package/src/sap/ui/model/odata/type/Single.js +1 -1
- package/src/sap/ui/model/odata/type/Stream.js +1 -1
- package/src/sap/ui/model/odata/type/String.js +1 -1
- package/src/sap/ui/model/odata/type/Time.js +1 -1
- package/src/sap/ui/model/odata/type/TimeOfDay.js +1 -1
- package/src/sap/ui/model/odata/type/Unit.js +1 -1
- package/src/sap/ui/model/odata/v2/Context.js +1 -1
- package/src/sap/ui/model/odata/v2/ODataAnnotations.js +1 -1
- package/src/sap/ui/model/odata/v2/ODataContextBinding.js +2 -2
- package/src/sap/ui/model/odata/v2/ODataListBinding.js +2 -2
- package/src/sap/ui/model/odata/v2/ODataModel.js +41 -59
- package/src/sap/ui/model/odata/v2/ODataTreeBinding.js +82 -60
- package/src/sap/ui/model/odata/v4/Context.js +1 -1
- package/src/sap/ui/model/odata/v4/ODataContextBinding.js +1 -1
- package/src/sap/ui/model/odata/v4/ODataListBinding.js +1 -1
- package/src/sap/ui/model/odata/v4/ODataMetaModel.js +35 -20
- package/src/sap/ui/model/odata/v4/ODataModel.js +1 -1
- package/src/sap/ui/model/odata/v4/ODataParentBinding.js +32 -5
- package/src/sap/ui/model/odata/v4/ODataPropertyBinding.js +1 -1
- package/src/sap/ui/model/odata/v4/lib/_AggregationCache.js +11 -1
- package/src/sap/ui/model/odata/v4/lib/_Cache.js +7 -9
- package/src/sap/ui/model/odata/v4/lib/_Helper.js +12 -12
- package/src/sap/ui/model/odata/v4/lib/_Requestor.js +16 -6
- package/src/sap/ui/model/resource/ResourceModel.js +1 -1
- package/src/sap/ui/model/type/Boolean.js +1 -1
- package/src/sap/ui/model/type/Currency.js +1 -1
- package/src/sap/ui/model/type/Date.js +1 -1
- package/src/sap/ui/model/type/DateInterval.js +1 -1
- package/src/sap/ui/model/type/DateTime.js +1 -1
- package/src/sap/ui/model/type/DateTimeInterval.js +1 -1
- package/src/sap/ui/model/type/FileSize.js +1 -1
- package/src/sap/ui/model/type/Float.js +1 -1
- package/src/sap/ui/model/type/Integer.js +1 -1
- package/src/sap/ui/model/type/String.js +1 -1
- package/src/sap/ui/model/type/Time.js +1 -1
- package/src/sap/ui/model/type/TimeInterval.js +1 -1
- package/src/sap/ui/model/type/Unit.js +19 -5
- package/src/sap/ui/model/xml/XMLModel.js +1 -1
- package/src/sap/ui/qunit/utils/ControlIterator.js +1 -2
- package/src/sap/ui/qunit/utils/MemoryLeakCheck.js +1 -1
- package/src/sap/ui/test/TestUtils.js +27 -15
- package/src/sap/ui/test/generic/TestBase.js +1 -1
- package/src/sap/ui/test/generic/Utils.js +6 -6
- package/src/sap/ui/test/opaQunit.js +3 -0
- package/src/sap/ui/thirdparty/qunit-2.js +4 -1
- package/src/sap/ui/util/Mobile.js +0 -9
- package/src/sap/ui/util/Storage.js +1 -1
- package/src/ui5loader.js +1 -1
- package/ui5.yaml +0 -1
- package/src/sap/ui/core/plugin/LessSupport.js +0 -542
|
@@ -4,874 +4,836 @@
|
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
5
5
|
*/
|
|
6
6
|
sap.ui.define([
|
|
7
|
-
'sap/ui/core/Lib',
|
|
8
7
|
'sap/ui/core/Theming',
|
|
9
8
|
'sap/ui/thirdparty/URI',
|
|
10
9
|
'../Element',
|
|
11
10
|
'sap/base/future',
|
|
12
11
|
'sap/base/Log',
|
|
13
|
-
'sap/base/util/extend',
|
|
14
12
|
'sap/base/util/syncFetch',
|
|
15
|
-
'sap/ui/
|
|
16
|
-
'./
|
|
17
|
-
],
|
|
18
|
-
|
|
13
|
+
'sap/ui/base/OwnStatics',
|
|
14
|
+
'./ThemeManager'
|
|
15
|
+
], function(
|
|
16
|
+
Theming,
|
|
17
|
+
URI,
|
|
18
|
+
Element,
|
|
19
|
+
future,
|
|
20
|
+
Log,
|
|
21
|
+
syncFetch,
|
|
22
|
+
OwnStatics,
|
|
23
|
+
ThemeManager
|
|
24
|
+
) {
|
|
19
25
|
"use strict";
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
27
|
+
const syncCallBehavior = sap.ui.loader._.getSyncCallBehavior();
|
|
28
|
+
const { attachChange } = OwnStatics.get(Theming);
|
|
29
|
+
const { getAllLibraryInfoObjects } = OwnStatics.get(ThemeManager);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A helper used for (read-only) access to CSS parameters at runtime.
|
|
33
|
+
*
|
|
34
|
+
* @author SAP SE
|
|
35
|
+
* @namespace
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @alias sap.ui.core.theming.Parameters
|
|
39
|
+
*/
|
|
40
|
+
var Parameters = {};
|
|
41
|
+
|
|
42
|
+
var mParameters = null;
|
|
43
|
+
var sTheme = null;
|
|
44
|
+
|
|
45
|
+
var aParametersToLoad = [...getAllLibraryInfoObjects().keys()];
|
|
46
|
+
|
|
47
|
+
var aCallbackRegistry = [];
|
|
48
|
+
|
|
49
|
+
var sBootstrapOrigin = new URI(sap.ui.require.toUrl(""), document.baseURI).origin();
|
|
50
|
+
var mOriginsNeedingCredentials = {};
|
|
51
|
+
|
|
52
|
+
// match a CSS url
|
|
53
|
+
var rCssUrl = /url[\s]*\('?"?([^\'")]*)'?"?\)/;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolves relative URLs in parameter values.
|
|
57
|
+
* Only for inline-parameters.
|
|
58
|
+
*
|
|
59
|
+
* Parameters containing CSS URLs will automatically be resolved to the theme-specific location they originate from.
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* A parameter for the "sap_horizon" theme will be resolved to a libraries "[library path...]/themes/sap_horizon" folder.
|
|
63
|
+
* Relative URLs can resolve backwards, too, so given the sample above, a parameter value of <code>url('../my_logo.jpeg')</code>
|
|
64
|
+
* will resolve to the "[library path...]/themes" folder.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} sUrl the relative URL to resolve
|
|
67
|
+
* @param {string} sThemeBaseUrl the theme base URL, pointing to the library that contains the parameter
|
|
68
|
+
* @returns {string} the resolved URL in CSS URL notation
|
|
69
|
+
*/
|
|
70
|
+
function checkAndResolveRelativeUrl(sUrl, sThemeBaseUrl) {
|
|
71
|
+
var aMatch = rCssUrl.exec(sUrl);
|
|
72
|
+
if (aMatch) {
|
|
73
|
+
var oUri = new URI(aMatch[1]);
|
|
74
|
+
if (oUri.is("relative")) {
|
|
75
|
+
// Rewrite relative URLs based on the theme base url
|
|
76
|
+
// Otherwise they would be relative to the HTML page which is incorrect
|
|
77
|
+
var sNormalizedUrl = oUri.absoluteTo(sThemeBaseUrl).normalize().toString();
|
|
78
|
+
sUrl = "url('" + sNormalizedUrl + "')";
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
return sUrl;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
return sUrl;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function mergeParameterSet(mCurrent, mNew, sThemeBaseUrl) {
|
|
86
|
+
for (var sParam in mNew) {
|
|
87
|
+
if (typeof mCurrent[sParam] === "undefined") {
|
|
88
|
+
mCurrent[sParam] = checkAndResolveRelativeUrl(mNew[sParam], sThemeBaseUrl);
|
|
84
89
|
}
|
|
85
|
-
return mCurrent;
|
|
86
90
|
}
|
|
91
|
+
return mCurrent;
|
|
92
|
+
}
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
function mergeParameters(mNewParameters, sThemeBaseUrl) {
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// normalize parameter maps
|
|
97
|
+
// scoped themes like sap_belize already provide nested objects:
|
|
98
|
+
if (typeof mNewParameters["default"] !== "object") {
|
|
99
|
+
mNewParameters = {
|
|
100
|
+
"default": mNewParameters,
|
|
101
|
+
"scopes": {}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
105
|
+
// ensure parameters objects
|
|
106
|
+
mParameters = mParameters || {};
|
|
107
|
+
mParameters["default"] = mParameters["default"] || {};
|
|
108
|
+
mParameters["scopes"] = mParameters["scopes"] || {};
|
|
109
|
+
|
|
110
|
+
// merge default parameters
|
|
111
|
+
mergeParameterSet(mParameters["default"], mNewParameters["default"], sThemeBaseUrl);
|
|
112
|
+
|
|
113
|
+
// merge scopes
|
|
114
|
+
if (typeof mNewParameters["scopes"] === "object") {
|
|
115
|
+
for (var sScopeName in mNewParameters["scopes"]) {
|
|
116
|
+
// ensure scope object
|
|
117
|
+
mParameters["scopes"][sScopeName] = mParameters["scopes"][sScopeName] || {};
|
|
118
|
+
// merge scope set
|
|
119
|
+
mergeParameterSet(mParameters["scopes"][sScopeName], mNewParameters["scopes"][sScopeName], sThemeBaseUrl);
|
|
115
120
|
}
|
|
116
121
|
}
|
|
122
|
+
}
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
124
|
+
function forEachStyleSheet(fnCallback) {
|
|
125
|
+
for (const [libId, libInfo] of getAllLibraryInfoObjects()) {
|
|
126
|
+
fnCallback(libId, libInfo);
|
|
122
127
|
}
|
|
128
|
+
}
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
function parseParameters(libInfo, bAsync) {
|
|
131
|
+
var oUrl = getThemeBaseUrlForId(libInfo);
|
|
126
132
|
|
|
127
|
-
|
|
133
|
+
var bThemeApplied = libInfo.finishedLoading;
|
|
128
134
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
if (!bThemeApplied && !bAsync) {
|
|
136
|
+
Log.warning("Parameters have been requested but theme is not applied, yet.", "sap.ui.core.theming.Parameters");
|
|
137
|
+
}
|
|
132
138
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
sParams = decodeURIComponent(sParams);
|
|
145
|
-
} catch (ex) {
|
|
146
|
-
future.warningThrows("Could not decode theme parameters URI from " + oUrl.styleSheetUrl, { cause: ex });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
139
|
+
// In some browsers (e.g. Safari) it might happen that after switching the theme or adopting the <link>'s href,
|
|
140
|
+
// the parameters from the previous stylesheet are taken. This can be prevented by checking whether the theme is applied.
|
|
141
|
+
if (bThemeApplied) {
|
|
142
|
+
var oLink = document.getElementById(libInfo.linkId);
|
|
143
|
+
var sDataUri = window.getComputedStyle(oLink).getPropertyValue("background-image");
|
|
144
|
+
var aParams = /\(["']?data:text\/plain;utf-8,(.*?)['"]?\)$/i.exec(sDataUri);
|
|
145
|
+
if (aParams && aParams.length >= 2) {
|
|
146
|
+
var sParams = aParams[1];
|
|
147
|
+
// decode only if necessary
|
|
148
|
+
if (sParams.charAt(0) !== "{" && sParams.charAt(sParams.length - 1) !== "}") {
|
|
149
149
|
try {
|
|
150
|
-
|
|
151
|
-
mergeParameters(oParams, oUrl.themeBaseUrl);
|
|
152
|
-
return true; // parameters successfully parsed
|
|
150
|
+
sParams = decodeURIComponent(sParams);
|
|
153
151
|
} catch (ex) {
|
|
154
|
-
future.warningThrows("Could not
|
|
152
|
+
future.warningThrows("Could not decode theme parameters URI from " + oUrl.styleSheetUrl, { cause: ex });
|
|
155
153
|
}
|
|
156
154
|
}
|
|
155
|
+
try {
|
|
156
|
+
var oParams = JSON.parse(sParams);
|
|
157
|
+
mergeParameters(oParams, oUrl.themeBaseUrl);
|
|
158
|
+
return true; // parameters successfully parsed
|
|
159
|
+
} catch (ex) {
|
|
160
|
+
future.warningThrows("Could not parse theme parameters from " + oUrl.styleSheetUrl + ".", { cause: ex , suffix: "Loading library-parameters.json as fallback solution." });
|
|
161
|
+
}
|
|
157
162
|
}
|
|
158
|
-
// sync: return false if parameter could not be parsed OR theme is not applied OR library has no parameters
|
|
159
|
-
// For sync path this triggers a sync library-parameters.json request as fallback
|
|
160
|
-
// async: always return bThemeApplied. Issues during parsing are not relevant for further processing because
|
|
161
|
-
// there is no fallback as in the sync case
|
|
162
|
-
return bAsync ? bThemeApplied : false;
|
|
163
163
|
}
|
|
164
|
+
// sync: return false if parameter could not be parsed OR theme is not applied OR library has no parameters
|
|
165
|
+
// For sync path this triggers a sync library-parameters.json request as fallback
|
|
166
|
+
// async: always return bThemeApplied. Issues during parsing are not relevant for further processing because
|
|
167
|
+
// there is no fallback as in the sync case
|
|
168
|
+
return bAsync ? bThemeApplied : false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Load parameters for a library/theme combination as identified by the URL of the library.css
|
|
173
|
+
* @param {object} libInfo Library info object from ThemeManager
|
|
174
|
+
*/
|
|
175
|
+
function loadParameters(libInfo) {
|
|
176
|
+
var oUrl = getThemeBaseUrlForId(libInfo);
|
|
177
|
+
|
|
178
|
+
// try to parse the inline-parameters for the given library
|
|
179
|
+
// this may fail for a number of reasons, see below
|
|
180
|
+
if (!parseParameters(libInfo)) {
|
|
181
|
+
// derive parameter file URL from CSS file URL
|
|
182
|
+
// $1: name of library (incl. variants)
|
|
183
|
+
// $2: additional parameters, e.g. for sap-ui-merged, version/sap-ui-dist-version
|
|
184
|
+
var sUrl = oUrl.styleSheetUrl.replace(/\/(?:css_variables|library)([^\/.]*)\.(?:css|less)($|[?#])/, function($0, $1, $2) {
|
|
185
|
+
return "/library-parameters.json" + ($2 ? $2 : "");
|
|
186
|
+
});
|
|
164
187
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// try to parse the inline-parameters for the given library
|
|
173
|
-
// this may fail for a number of reasons, see below
|
|
174
|
-
if (!parseParameters(sId)) {
|
|
175
|
-
// derive parameter file URL from CSS file URL
|
|
176
|
-
// $1: name of library (incl. variants)
|
|
177
|
-
// $2: additional parameters, e.g. for sap-ui-merged, version/sap-ui-dist-version
|
|
178
|
-
var sUrl = oUrl.styleSheetUrl.replace(/\/(?:css_variables|library)([^\/.]*)\.(?:css|less)($|[?#])/, function($0, $1, $2) {
|
|
179
|
-
return "/library-parameters.json" + ($2 ? $2 : "");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
if (syncCallBehavior === 2) {
|
|
183
|
-
Log.error("[nosync] Loading library-parameters.json ignored", sUrl, "sap.ui.core.theming.Parameters");
|
|
184
|
-
return;
|
|
185
|
-
} else if (syncCallBehavior === 1) {
|
|
186
|
-
Log.error("[nosync] Loading library-parameters.json with sync XHR", sUrl, "sap.ui.core.theming.Parameters");
|
|
187
|
-
}
|
|
188
|
+
if (syncCallBehavior === 2) {
|
|
189
|
+
Log.error("[nosync] Loading library-parameters.json ignored", sUrl, "sap.ui.core.theming.Parameters");
|
|
190
|
+
return;
|
|
191
|
+
} else if (syncCallBehavior === 1) {
|
|
192
|
+
Log.error("[nosync] Loading library-parameters.json with sync XHR", sUrl, "sap.ui.core.theming.Parameters");
|
|
193
|
+
}
|
|
188
194
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} else {
|
|
201
|
-
aWithCredentials = [true, false];
|
|
202
|
-
}
|
|
195
|
+
// check if we need to send credentials
|
|
196
|
+
var sThemeOrigin = new URI(oUrl.themeBaseUrl).origin();
|
|
197
|
+
var bWithCredentials = mOriginsNeedingCredentials[sThemeOrigin];
|
|
198
|
+
var aWithCredentials = [];
|
|
199
|
+
|
|
200
|
+
// initially we don't have any information if the target origin needs credentials or not ...
|
|
201
|
+
if (bWithCredentials === undefined) {
|
|
202
|
+
// ... so we assume that for all cross-origins except the UI5 bootstrap we need credentials.
|
|
203
|
+
// Setting the XHR's "withCredentials" flag does not do anything for same origin requests.
|
|
204
|
+
if (sUrl.startsWith(sBootstrapOrigin)) {
|
|
205
|
+
aWithCredentials = [false, true];
|
|
203
206
|
} else {
|
|
204
|
-
aWithCredentials = [
|
|
207
|
+
aWithCredentials = [true, false];
|
|
205
208
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
loadParametersJSON(sUrl, oUrl.themeBaseUrl, aWithCredentials);
|
|
209
|
+
} else {
|
|
210
|
+
aWithCredentials = [bWithCredentials];
|
|
209
211
|
}
|
|
212
|
+
|
|
213
|
+
// trigger a sync. loading of the parameters.json file
|
|
214
|
+
loadParametersJSON(sUrl, oUrl.themeBaseUrl, aWithCredentials);
|
|
210
215
|
}
|
|
216
|
+
}
|
|
211
217
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
function getThemeBaseUrlForId (libInfo) {
|
|
219
|
+
if (!libInfo.getUrl().url && !libInfo.cssLinkElement) {
|
|
220
|
+
future.warningThrows(`sap.ui.core.theming.Parameters: Could not find stylesheet element with ID "${libInfo.id}"`);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
216
223
|
|
|
217
|
-
|
|
218
|
-
future.warningThrows(`sap.ui.core.theming.Parameters: Could not find stylesheet element with ID "${sId}"`);
|
|
219
|
-
return undefined;
|
|
220
|
-
}
|
|
224
|
+
var sStyleSheetUrl = libInfo.getUrl().url || libInfo.cssLinkElement?.getAttribute("href");
|
|
221
225
|
|
|
222
|
-
|
|
226
|
+
// Remove CSS file name and query to create theme base url (to resolve relative urls)
|
|
227
|
+
return {
|
|
228
|
+
themeBaseUrl: new URI(sStyleSheetUrl).filename("").query("").toString(),
|
|
229
|
+
styleSheetUrl : sStyleSheetUrl
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Loads a parameters.json file from given URL.
|
|
235
|
+
* @param {string} sUrl URL
|
|
236
|
+
* @param {string} sThemeBaseUrl Base URL
|
|
237
|
+
* @param {boolean[]} aWithCredentials probing values for requesting with or without credentials
|
|
238
|
+
*/
|
|
239
|
+
function loadParametersJSON(sUrl, sThemeBaseUrl, aWithCredentials) {
|
|
240
|
+
var oHeaders = {
|
|
241
|
+
Accept: syncFetch.ContentTypes.JSON
|
|
242
|
+
};
|
|
223
243
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
244
|
+
var bCurrentWithCredentials = aWithCredentials.shift();
|
|
245
|
+
if (bCurrentWithCredentials) {
|
|
246
|
+
// the X-Requested-With Header is essential for the Theming-Service to determine if a GET request will be handled
|
|
247
|
+
// This forces a preflight request which should give us valid Allow headers:
|
|
248
|
+
// Access-Control-Allow-Origin: ... fully qualified requestor origin ...
|
|
249
|
+
// Access-Control-Allow-Credentials: true
|
|
250
|
+
oHeaders["X-Requested-With"] = "XMLHttpRequest";
|
|
229
251
|
}
|
|
230
252
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// Access-Control-Allow-Credentials: true
|
|
248
|
-
oHeaders["X-Requested-With"] = "XMLHttpRequest";
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function fnErrorCallback(error) {
|
|
252
|
-
// ignore failure at least temporarily as long as there are libraries built using outdated tools which produce no json file
|
|
253
|
-
future.errorThrows("Could not load theme parameters from: " + sUrl, { cause: error }); // could be an error as well, but let's avoid more CSN messages...
|
|
254
|
-
|
|
255
|
-
if (aWithCredentials.length > 0) {
|
|
256
|
-
// In a CORS scenario, IF we have sent credentials on the first try AND the request failed,
|
|
257
|
-
// we expect that a service could have answered with the following Allow header:
|
|
258
|
-
// Access-Control-Allow-Origin: *
|
|
259
|
-
// In this case we must not send credentials, otherwise the service would have answered with:
|
|
260
|
-
// Access-Control-Allow-Origin: https://...
|
|
261
|
-
// Access-Control-Allow-Credentials: true
|
|
262
|
-
// Due to security constraints, the browser does not hand out any more information in a CORS scenario,
|
|
263
|
-
// so now we try again without credentials.
|
|
264
|
-
Log.warning("Initial library-parameters.json request failed ('withCredentials=" + bCurrentWithCredentials + "'; sUrl: '" + sUrl + "').\n" +
|
|
265
|
-
"Retrying with 'withCredentials=" + !bCurrentWithCredentials + "'.", "sap.ui.core.theming.Parameters");
|
|
266
|
-
loadParametersJSON(sUrl, sThemeBaseUrl, aWithCredentials);
|
|
267
|
-
}
|
|
253
|
+
function fnErrorCallback(error) {
|
|
254
|
+
// ignore failure at least temporarily as long as there are libraries built using outdated tools which produce no json file
|
|
255
|
+
future.errorThrows("Could not load theme parameters from: " + sUrl, { cause: error }); // could be an error as well, but let's avoid more CSN messages...
|
|
256
|
+
|
|
257
|
+
if (aWithCredentials.length > 0) {
|
|
258
|
+
// In a CORS scenario, IF we have sent credentials on the first try AND the request failed,
|
|
259
|
+
// we expect that a service could have answered with the following Allow header:
|
|
260
|
+
// Access-Control-Allow-Origin: *
|
|
261
|
+
// In this case we must not send credentials, otherwise the service would have answered with:
|
|
262
|
+
// Access-Control-Allow-Origin: https://...
|
|
263
|
+
// Access-Control-Allow-Credentials: true
|
|
264
|
+
// Due to security constraints, the browser does not hand out any more information in a CORS scenario,
|
|
265
|
+
// so now we try again without credentials.
|
|
266
|
+
Log.warning("Initial library-parameters.json request failed ('withCredentials=" + bCurrentWithCredentials + "'; sUrl: '" + sUrl + "').\n" +
|
|
267
|
+
"Retrying with 'withCredentials=" + !bCurrentWithCredentials + "'.", "sap.ui.core.theming.Parameters");
|
|
268
|
+
loadParametersJSON(sUrl, sThemeBaseUrl, aWithCredentials);
|
|
268
269
|
}
|
|
270
|
+
}
|
|
269
271
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
mergeParameters(data, sThemeBaseUrl);
|
|
272
|
+
// load and evaluate parameter file
|
|
273
|
+
try {
|
|
274
|
+
var response = syncFetch(sUrl, {
|
|
275
|
+
credentials: bCurrentWithCredentials ? "include" : "omit",
|
|
276
|
+
headers: oHeaders
|
|
277
|
+
});
|
|
278
|
+
if (response.ok) {
|
|
279
|
+
var data = response.json();
|
|
280
|
+
// Once we have a successful request we track the credentials setting for this origin
|
|
281
|
+
var sThemeOrigin = new URI(sThemeBaseUrl).origin();
|
|
282
|
+
mOriginsNeedingCredentials[sThemeOrigin] = bCurrentWithCredentials;
|
|
283
|
+
|
|
284
|
+
if (Array.isArray(data)) {
|
|
285
|
+
// in the sap-ui-merged use case, multiple JSON files are merged into and transferred as a single JSON array
|
|
286
|
+
for (var j = 0; j < data.length; j++) {
|
|
287
|
+
var oParams = data[j];
|
|
288
|
+
mergeParameters(oParams, sThemeBaseUrl);
|
|
290
289
|
}
|
|
291
290
|
} else {
|
|
292
|
-
|
|
291
|
+
mergeParameters(data, sThemeBaseUrl);
|
|
293
292
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
fnErrorCallback(error);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Retrieves a map containing all inline-parameters.
|
|
302
|
-
*
|
|
303
|
-
* @param {boolean} bAsync=undefined whether to load and parse the parameters asynchronously, default sync
|
|
304
|
-
* @returns {object} a map of all parameters
|
|
305
|
-
*/
|
|
306
|
-
function getParameters(bAsync) {
|
|
307
|
-
// Initial loading
|
|
308
|
-
if (!mParameters) {
|
|
309
|
-
// Merge an empty parameter set to initialize the internal object
|
|
310
|
-
mergeParameters({}, "");
|
|
311
|
-
|
|
312
|
-
forEachStyleSheet(function (sId) {
|
|
313
|
-
if (bAsync) {
|
|
314
|
-
if (!parseParameters(sId, bAsync)) {
|
|
315
|
-
aParametersToLoad.push(sId);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
loadParameters(sId);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
293
|
+
} else {
|
|
294
|
+
throw new Error(response.statusText || response.status);
|
|
321
295
|
}
|
|
322
296
|
|
|
323
|
-
|
|
297
|
+
} catch (error) {
|
|
298
|
+
fnErrorCallback(error);
|
|
324
299
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Retrieves a map containing all inline-parameters.
|
|
304
|
+
*
|
|
305
|
+
* @param {boolean} bAsync=undefined whether to load and parse the parameters asynchronously, default sync
|
|
306
|
+
* @returns {object} a map of all parameters
|
|
307
|
+
*/
|
|
308
|
+
function getParameters(bAsync) {
|
|
309
|
+
// Initial loading
|
|
310
|
+
if (!mParameters) {
|
|
311
|
+
// Merge an empty parameter set to initialize the internal object
|
|
312
|
+
mergeParameters({}, "");
|
|
313
|
+
|
|
314
|
+
forEachStyleSheet(function (libId, libInfo) {
|
|
315
|
+
if (bAsync) {
|
|
316
|
+
if (!parseParameters(libInfo, bAsync)) {
|
|
317
|
+
aParametersToLoad.push(libId);
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
loadParameters(libInfo);
|
|
333
321
|
}
|
|
334
322
|
});
|
|
335
|
-
|
|
336
|
-
// Keep theme IDs which are not ready for later
|
|
337
|
-
aParametersToLoad = aPendingThemes;
|
|
338
323
|
}
|
|
339
324
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
*/
|
|
343
|
-
function loadPendingLibraryParameters() {
|
|
344
|
-
// lazy loading of further library parameters
|
|
345
|
-
aParametersToLoad.forEach(loadParameters);
|
|
346
|
-
|
|
347
|
-
// clear queue
|
|
348
|
-
aParametersToLoad = [];
|
|
349
|
-
}
|
|
325
|
+
return mParameters;
|
|
326
|
+
}
|
|
350
327
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
* Must be called AFTER a link-tag (with id: "sap-ui-theme" + sLibName) for the theme has been created.
|
|
354
|
-
* @param {string} sLibId id of theme link-tag
|
|
355
|
-
* @private
|
|
356
|
-
*/
|
|
357
|
-
Parameters._addLibraryTheme = function(sLibId) {
|
|
358
|
-
// only queue new libraries if some have been loaded already
|
|
359
|
-
// otherwise they will be loaded when the first one requests a parameter
|
|
360
|
-
// see "Parameters.get" for lazy loading of queued library parameters
|
|
361
|
-
if (mParameters) {
|
|
362
|
-
aParametersToLoad.push("sap-ui-theme-" + sLibId);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
328
|
+
function parsePendingLibraryParameters() {
|
|
329
|
+
var aPendingThemes = [];
|
|
365
330
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
* @param {string} mOptions.parameterName Parameter name / key
|
|
371
|
-
* @param {string} mOptions.scopeName Scope name
|
|
372
|
-
* @param {boolean} mOptions.loadPendingParameters If set to "true" and no parameter value is found,
|
|
373
|
-
* all pending parameters will be loaded (see Parameters._addLibraryTheme)
|
|
374
|
-
* @param {boolean} mOptions.async whether the parameter value should be retrieved asynchronous
|
|
375
|
-
* @returns {string|undefined} parameter value or undefined
|
|
376
|
-
* @private
|
|
377
|
-
*/
|
|
378
|
-
function getParam(mOptions) {
|
|
379
|
-
var bAsync = mOptions.async, oParams = getParameters(bAsync);
|
|
380
|
-
if (mOptions.scopeName) {
|
|
381
|
-
oParams = oParams["scopes"][mOptions.scopeName];
|
|
382
|
-
} else {
|
|
383
|
-
oParams = oParams["default"];
|
|
331
|
+
aParametersToLoad.forEach(function (sId) {
|
|
332
|
+
// Try to parse parameters (in case theme is already applied). Else keep parameter ID for later
|
|
333
|
+
if (!parseParameters(getAllLibraryInfoObjects(sId), /*bAsync=*/true)) {
|
|
334
|
+
aPendingThemes.push(sId);
|
|
384
335
|
}
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// Keep theme IDs which are not ready for later
|
|
339
|
+
aParametersToLoad = aPendingThemes;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Loads library-parameters.json files if some libraries are missing.
|
|
344
|
+
*/
|
|
345
|
+
function loadPendingLibraryParameters() {
|
|
346
|
+
// lazy loading of further library parameters
|
|
347
|
+
aParametersToLoad.map((id) => getAllLibraryInfoObjects(id)).forEach(loadParameters);
|
|
348
|
+
|
|
349
|
+
// clear queue
|
|
350
|
+
aParametersToLoad = [];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Called by the Core when a new library and its stylesheet have been loaded.
|
|
355
|
+
* Must be called AFTER a link-tag (with id: "sap-ui-theme" + sLibName) for the theme has been created.
|
|
356
|
+
* @param {string} sLibId id of theme link-tag
|
|
357
|
+
* @private
|
|
358
|
+
*/
|
|
359
|
+
Parameters._addLibraryTheme = function(sLibId) {
|
|
360
|
+
aParametersToLoad.push(sLibId);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Returns parameter value from given map and handles legacy parameter names
|
|
365
|
+
*
|
|
366
|
+
* @param {object} mOptions options map
|
|
367
|
+
* @param {string} mOptions.parameterName Parameter name / key
|
|
368
|
+
* @param {string} mOptions.scopeName Scope name
|
|
369
|
+
* @param {boolean} mOptions.loadPendingParameters If set to "true" and no parameter value is found,
|
|
370
|
+
* all pending parameters will be loaded (see Parameters._addLibraryTheme)
|
|
371
|
+
* @param {boolean} mOptions.async whether the parameter value should be retrieved asynchronous
|
|
372
|
+
* @returns {string|undefined} parameter value or undefined
|
|
373
|
+
* @private
|
|
374
|
+
*/
|
|
375
|
+
function getParam(mOptions) {
|
|
376
|
+
var bAsync = mOptions.async, oParams = getParameters(bAsync);
|
|
377
|
+
if (mOptions.scopeName) {
|
|
378
|
+
oParams = oParams["scopes"][mOptions.scopeName];
|
|
379
|
+
} else {
|
|
380
|
+
oParams = oParams["default"];
|
|
381
|
+
}
|
|
385
382
|
|
|
386
|
-
|
|
383
|
+
var sParamValue = oParams[mOptions.parameterName];
|
|
387
384
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
385
|
+
// [Compatibility]: if a parameter contains a prefix, we cut off the ":" and try again
|
|
386
|
+
// e.g. "my.lib:paramName"
|
|
387
|
+
if (!sParamValue) {
|
|
388
|
+
var iIndex = mOptions.parameterName.indexOf(":");
|
|
389
|
+
if (iIndex != -1) {
|
|
390
|
+
var sParamNameWithoutColon = mOptions.parameterName.substr(iIndex + 1);
|
|
391
|
+
sParamValue = oParams[sParamNameWithoutColon];
|
|
396
392
|
}
|
|
393
|
+
}
|
|
397
394
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
// is added asynchronous after initLibrary has been executed
|
|
402
|
-
var aAllLibrariesRequireCss = Library.getAllInstancesRequiringCss();
|
|
403
|
-
aAllLibrariesRequireCss.forEach(function (oLibThemingInfo) {
|
|
404
|
-
ThemeManager._includeLibraryThemeAndEnsureThemeRoot(oLibThemingInfo);
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
loadPendingLibraryParameters();
|
|
408
|
-
sParamValue = getParam({
|
|
409
|
-
parameterName: mOptions.parameterName,
|
|
410
|
-
scopeName: mOptions.scopeName,
|
|
411
|
-
loadPendingParameters: false // prevent recursion
|
|
412
|
-
});
|
|
413
|
-
}
|
|
395
|
+
// Sync: Fallback path for when parameter could not be found so far, library.css MIGHT be not loaded
|
|
396
|
+
if (mOptions.loadPendingParameters && typeof sParamValue === "undefined" && !bAsync) {
|
|
397
|
+
loadPendingLibraryParameters();
|
|
414
398
|
|
|
415
|
-
|
|
399
|
+
sParamValue = getParam({
|
|
400
|
+
parameterName: mOptions.parameterName,
|
|
401
|
+
scopeName: mOptions.scopeName,
|
|
402
|
+
loadPendingParameters: false // prevent recursion
|
|
403
|
+
});
|
|
416
404
|
}
|
|
417
405
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
var aScopeChain = Parameters.getActiveScopesFor(oElement, bAsync);
|
|
406
|
+
return sParamValue;
|
|
407
|
+
}
|
|
421
408
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
return aResult;
|
|
427
|
-
}, []);
|
|
409
|
+
function getParamForActiveScope(sParamName, oElement, bAsync) {
|
|
410
|
+
// check for scopes and try to find the classes in Control Tree
|
|
411
|
+
var aScopeChain = Parameters.getActiveScopesFor(oElement, bAsync);
|
|
428
412
|
|
|
429
|
-
|
|
430
|
-
|
|
413
|
+
var aFilteredScopeChain = aScopeChain.flat().reduce(function (aResult, sScope) {
|
|
414
|
+
if (aResult.indexOf(sScope) === -1) {
|
|
415
|
+
aResult.push(sScope);
|
|
416
|
+
}
|
|
417
|
+
return aResult;
|
|
418
|
+
}, []);
|
|
431
419
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
scopeName: sScopeName,
|
|
435
|
-
async: bAsync
|
|
436
|
-
});
|
|
420
|
+
for (var i = 0; i < aFilteredScopeChain.length; i++) {
|
|
421
|
+
var sScopeName = aFilteredScopeChain[i];
|
|
437
422
|
|
|
438
|
-
|
|
439
|
-
return sParamValue;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
// if no matching scope was found return the default parameter
|
|
443
|
-
return getParam({
|
|
423
|
+
var sParamValue = getParam({
|
|
444
424
|
parameterName: sParamName,
|
|
425
|
+
scopeName: sScopeName,
|
|
445
426
|
async: bAsync
|
|
446
427
|
});
|
|
447
|
-
}
|
|
448
428
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
429
|
+
if (sParamValue) {
|
|
430
|
+
return sParamValue;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// if no matching scope was found return the default parameter
|
|
434
|
+
return getParam({
|
|
435
|
+
parameterName: sParamName,
|
|
436
|
+
async: bAsync
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Returns the scopes from current theming parameters.
|
|
442
|
+
*
|
|
443
|
+
* @private
|
|
444
|
+
* @ui5-restricted sap.ui.core
|
|
445
|
+
* @param {boolean} [bAvoidLoading] Whether loading of parameters should be avoided
|
|
446
|
+
* @param {boolean} [bAsync] Whether loading of parameters should be asynchronous
|
|
447
|
+
* @return {string[]|undefined} Scope names
|
|
448
|
+
*/
|
|
449
|
+
Parameters._getScopes = function(bAvoidLoading, bAsync) {
|
|
450
|
+
if ( bAvoidLoading && !mParameters ) {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
var oParams = getParameters(bAsync);
|
|
454
|
+
var aScopes = Object.keys(oParams["scopes"]);
|
|
455
|
+
return aScopes;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Returns the active scope(s) for a given control by looking up the hierarchy.
|
|
460
|
+
*
|
|
461
|
+
* The lookup navigates the DOM hierarchy if it's available. Otherwise if controls aren't rendered yet,
|
|
462
|
+
* it navigates the control hierarchy. By navigating the control hierarchy, inner-html elements
|
|
463
|
+
* with the respective scope classes can't get recognized as the Custom Style Class API does only for
|
|
464
|
+
* root elements.
|
|
465
|
+
*
|
|
466
|
+
* @private
|
|
467
|
+
* @ui5-restricted sap.viz
|
|
468
|
+
* @param {object} oElement element/control instance
|
|
469
|
+
* @param {boolean} bAsync Whether the scope should be retrieved asynchronous
|
|
470
|
+
* @return {Array.<Array.<string>>} Two dimensional array with scopes in bottom up order
|
|
471
|
+
*/
|
|
472
|
+
Parameters.getActiveScopesFor = function(oElement, bAsync) {
|
|
473
|
+
var aScopeChain = [];
|
|
474
|
+
|
|
475
|
+
if (oElement instanceof Element) {
|
|
476
|
+
var domRef = oElement.getDomRef();
|
|
477
|
+
|
|
478
|
+
// make sure to first load all pending parameters
|
|
479
|
+
// doing it later (lazy) might change the behavior in case a scope is initially not defined
|
|
480
|
+
if (bAsync) {
|
|
481
|
+
parsePendingLibraryParameters();
|
|
482
|
+
} else {
|
|
483
|
+
loadPendingLibraryParameters();
|
|
461
484
|
}
|
|
462
|
-
var oParams = getParameters(bAsync);
|
|
463
|
-
var aScopes = Object.keys(oParams["scopes"]);
|
|
464
|
-
return aScopes;
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Returns the active scope(s) for a given control by looking up the hierarchy.
|
|
469
|
-
*
|
|
470
|
-
* The lookup navigates the DOM hierarchy if it's available. Otherwise if controls aren't rendered yet,
|
|
471
|
-
* it navigates the control hierarchy. By navigating the control hierarchy, inner-html elements
|
|
472
|
-
* with the respective scope classes can't get recognized as the Custom Style Class API does only for
|
|
473
|
-
* root elements.
|
|
474
|
-
*
|
|
475
|
-
* @private
|
|
476
|
-
* @ui5-restricted sap.viz
|
|
477
|
-
* @param {object} oElement element/control instance
|
|
478
|
-
* @param {boolean} bAsync Whether the scope should be retrieved asynchronous
|
|
479
|
-
* @return {Array.<Array.<string>>} Two dimensional array with scopes in bottom up order
|
|
480
|
-
*/
|
|
481
|
-
Parameters.getActiveScopesFor = function(oElement, bAsync) {
|
|
482
|
-
var aScopeChain = [];
|
|
483
485
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
// check for scopes and try to find the classes in parent chain
|
|
487
|
+
var aScopes = this._getScopes(undefined, bAsync);
|
|
486
488
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
489
|
+
if (aScopes.length) {
|
|
490
|
+
if (domRef) {
|
|
491
|
+
var fnNodeHasStyleClass = function(sScopeName) {
|
|
492
|
+
var scopeList = domRef.classList;
|
|
493
|
+
return scopeList && scopeList.contains(sScopeName);
|
|
494
|
+
};
|
|
494
495
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (domRef) {
|
|
500
|
-
var fnNodeHasStyleClass = function(sScopeName) {
|
|
501
|
-
var scopeList = domRef.classList;
|
|
502
|
-
return scopeList && scopeList.contains(sScopeName);
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
while (domRef) {
|
|
506
|
-
var aFoundScopeClasses = aScopes.filter(fnNodeHasStyleClass);
|
|
507
|
-
if (aFoundScopeClasses.length > 0) {
|
|
508
|
-
aScopeChain.push(aFoundScopeClasses);
|
|
509
|
-
}
|
|
510
|
-
domRef = domRef.parentNode;
|
|
496
|
+
while (domRef) {
|
|
497
|
+
const aFoundScopeClasses = aScopes.filter(fnNodeHasStyleClass);
|
|
498
|
+
if (aFoundScopeClasses.length > 0) {
|
|
499
|
+
aScopeChain.push(aFoundScopeClasses);
|
|
511
500
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
501
|
+
domRef = domRef.parentNode;
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
var fnControlHasStyleClass = function(sScopeName) {
|
|
505
|
+
return typeof oElement.hasStyleClass === "function" && oElement.hasStyleClass(sScopeName);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
while (oElement) {
|
|
509
|
+
const aFoundScopeClasses = aScopes.filter(fnControlHasStyleClass);
|
|
510
|
+
if (aFoundScopeClasses.length > 0) {
|
|
511
|
+
aScopeChain.push(aFoundScopeClasses);
|
|
523
512
|
}
|
|
513
|
+
oElement = typeof oElement.getParent === "function" && oElement.getParent();
|
|
524
514
|
}
|
|
525
515
|
}
|
|
526
516
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
517
|
+
}
|
|
518
|
+
return aScopeChain;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
*
|
|
523
|
+
* Theming Parameter Value
|
|
524
|
+
*
|
|
525
|
+
* @typedef {(string|Object<string,string>|undefined)} sap.ui.core.theming.Parameters.Value
|
|
526
|
+
* @public
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* <p>
|
|
531
|
+
* Returns the current value for one or more theming parameters, depending on the given arguments.
|
|
532
|
+
* The synchronous usage of this API has been deprecated and only the asynchronous usage should still be used
|
|
533
|
+
* (see the 4th bullet point and the code examples below).
|
|
534
|
+
* </p>
|
|
535
|
+
*
|
|
536
|
+
* <p>
|
|
537
|
+
* The theming parameters are immutable and cannot be changed at runtime.
|
|
538
|
+
* Multiple <code>Parameters.get()</code> API calls for the same parameter name will always result in the same parameter value.
|
|
539
|
+
* </p>
|
|
540
|
+
*
|
|
541
|
+
* <p>
|
|
542
|
+
* The following API variants are available (see also the below examples):
|
|
543
|
+
* <ul>
|
|
544
|
+
* <li> <b>(deprecated since 1.92)</b> If no parameter is given a key-value map containing all parameters is returned</li>
|
|
545
|
+
* <li> <b>(deprecated since 1.94)</b> If a <code>string</code> is given as first parameter the value is returned as a <code>string</code></li>
|
|
546
|
+
* <li> <b>(deprecated since 1.94)</b> If an <code>array</code> is given as first parameter a key-value map containing all parameters from the <code>array</code> is returned</li>
|
|
547
|
+
* <li>If an <code>object</code> is given as first parameter the result is returned immediately in case all parameters are loaded and available or within the callback in case not all CSS files are already loaded.
|
|
548
|
+
* This is the <b>only asynchronous</b> API variant. This variant is the preferred way to retrieve theming parameters.
|
|
549
|
+
* The structure of the return value is the same as listed above depending on the type of the name property within the <code>object</code>.</li>
|
|
550
|
+
* </ul>
|
|
551
|
+
* </p>
|
|
552
|
+
*
|
|
553
|
+
* <p>The returned key-value maps are a copy so changing values in the map does not have any effect</p>
|
|
554
|
+
*
|
|
555
|
+
* <p>
|
|
556
|
+
* Please see the examples below for a detailed guide on how to use the <b>asynchronous variant</b> of the API.
|
|
557
|
+
* </p>
|
|
558
|
+
*
|
|
559
|
+
* @example <caption>Scenario 1: Parameters are already available</caption>
|
|
560
|
+
* // "sapUiParam1", "sapUiParam2", "sapUiParam3" are already available
|
|
561
|
+
* Parameters.get({
|
|
562
|
+
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
563
|
+
* callback: function(mParams) {
|
|
564
|
+
* // callback is not called, since all Parameters are available synchronously
|
|
565
|
+
* }
|
|
566
|
+
* });
|
|
567
|
+
* // As described above, returns a map with key-value pairs corresponding to the parameters:
|
|
568
|
+
* // mParams = {sapUiParam1: '...value...', sapUiParam2: '...value...', sapUiParam3: '...value...'}
|
|
569
|
+
*
|
|
570
|
+
* @example <caption>Scenario 2: Some Parameters are missing </caption>
|
|
571
|
+
* // "sapUiParam1", "sapUiParam2" are already available
|
|
572
|
+
* // "sapUiParam3" is not yet available
|
|
573
|
+
* Parameters.get({
|
|
574
|
+
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
575
|
+
* callback: function(mParams) {
|
|
576
|
+
* // Parameters.get() callback gets the same map with key-value pairs as in "Scenario 1".
|
|
577
|
+
* // mParams = {sapUiParam1: '...value...', sapUiParam2: '...value...', sapUiParam3: '...value...'}
|
|
578
|
+
* }
|
|
579
|
+
* });
|
|
580
|
+
* // return-value is undefined, since not all Parameters are yet available synchronously
|
|
581
|
+
*
|
|
582
|
+
* @example <caption>Scenario 3: Default values</caption>
|
|
583
|
+
* // Scenario 1 (all parameters are available): the returned parameter map can be used to merge with a map of default values.
|
|
584
|
+
* // Scenario 2 (one or more parameters are missing): the returned undefined value does not change the default parameters
|
|
585
|
+
* // This allows you to always retrieve a consistent set of parameters, either synchronously via the return-value or asynchronously via the provided callback.
|
|
586
|
+
* var mMyParams = Object.assign({
|
|
587
|
+
* sapUiParam1: "1rem",
|
|
588
|
+
* sapUiParam2: "#FF0000",
|
|
589
|
+
* sapUiParam3: "16px"
|
|
590
|
+
* }, Parameters.get({
|
|
591
|
+
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
592
|
+
* callback: function(mParams) {
|
|
593
|
+
* // merge the current parameters with the actual parameters in case they are retrieved asynchronously
|
|
594
|
+
* Object.assign(mMyParams, mParams);
|
|
595
|
+
* }
|
|
596
|
+
* }));
|
|
597
|
+
*
|
|
598
|
+
* @param {string | string[] | object} vName the (array with) CSS parameter name(s) or an object containing the (array with) CSS parameter name(s),
|
|
599
|
+
* the scopeElement and a callback for async retrieval of parameters.
|
|
600
|
+
* @param {string | string[]} vName.name the (array with) CSS parameter name(s)
|
|
601
|
+
* @param {sap.ui.core.Element} [vName.scopeElement]
|
|
602
|
+
* Element / control instance to take into account when looking for a parameter value.
|
|
603
|
+
* This can make a difference when a parameter value is overridden in a theme scope set via a CSS class.
|
|
604
|
+
* @param {function(sap.ui.core.theming.Parameters.Value)} [vName.callback] If given, the callback is only executed in case there are still parameters pending and one or more of the requested parameters is missing.
|
|
605
|
+
* @param {sap.ui.core.Element} [oElement]
|
|
606
|
+
* Element / control instance to take into account when looking for a parameter value.
|
|
607
|
+
* This can make a difference when a parameter value is overridden in a theme scope set via a CSS class.
|
|
608
|
+
* @returns {sap.ui.core.theming.Parameters.Value} the CSS parameter value(s) or <code>undefined</code> if the parameters could not be retrieved.
|
|
609
|
+
*
|
|
610
|
+
* @public
|
|
611
|
+
*/
|
|
612
|
+
Parameters.get = function(vName, oElement) {
|
|
613
|
+
let sParamName, fnAsyncCallback, bAsync, aNames, iIndex;
|
|
614
|
+
|
|
615
|
+
// Whether parameters containing CSS URLs should be parsed into regular URL strings,
|
|
616
|
+
// e.g. a parameter value of url('https://myapp.sample/image.jpeg') will be returned as "https://myapp.sample/image.jpeg".
|
|
617
|
+
// Empty strings as well as the special CSS value 'none' will be parsed to null.
|
|
618
|
+
let bParseUrls;
|
|
619
|
+
|
|
620
|
+
var findRegisteredCallback = function (oCallbackInfo) { return oCallbackInfo.callback === fnAsyncCallback; };
|
|
621
|
+
|
|
622
|
+
if (!sTheme) {
|
|
623
|
+
sTheme = Theming.getTheme();
|
|
624
|
+
}
|
|
537
625
|
|
|
538
626
|
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* (see the 4th bullet point and the code examples below).
|
|
543
|
-
* </p>
|
|
544
|
-
*
|
|
545
|
-
* <p>
|
|
546
|
-
* The theming parameters are immutable and cannot be changed at runtime.
|
|
547
|
-
* Multiple <code>Parameters.get()</code> API calls for the same parameter name will always result in the same parameter value.
|
|
548
|
-
* </p>
|
|
549
|
-
*
|
|
550
|
-
* <p>
|
|
551
|
-
* The following API variants are available (see also the below examples):
|
|
552
|
-
* <ul>
|
|
553
|
-
* <li> <b>(deprecated since 1.92)</b> If no parameter is given a key-value map containing all parameters is returned</li>
|
|
554
|
-
* <li> <b>(deprecated since 1.94)</b> If a <code>string</code> is given as first parameter the value is returned as a <code>string</code></li>
|
|
555
|
-
* <li> <b>(deprecated since 1.94)</b> If an <code>array</code> is given as first parameter a key-value map containing all parameters from the <code>array</code> is returned</li>
|
|
556
|
-
* <li>If an <code>object</code> is given as first parameter the result is returned immediately in case all parameters are loaded and available or within the callback in case not all CSS files are already loaded.
|
|
557
|
-
* This is the <b>only asynchronous</b> API variant. This variant is the preferred way to retrieve theming parameters.
|
|
558
|
-
* The structure of the return value is the same as listed above depending on the type of the name property within the <code>object</code>.</li>
|
|
559
|
-
* </ul>
|
|
560
|
-
* </p>
|
|
561
|
-
*
|
|
562
|
-
* <p>The returned key-value maps are a copy so changing values in the map does not have any effect</p>
|
|
563
|
-
*
|
|
564
|
-
* <p>
|
|
565
|
-
* Please see the examples below for a detailed guide on how to use the <b>asynchronous variant</b> of the API.
|
|
566
|
-
* </p>
|
|
567
|
-
*
|
|
568
|
-
* @example <caption>Scenario 1: Parameters are already available</caption>
|
|
569
|
-
* // "sapUiParam1", "sapUiParam2", "sapUiParam3" are already available
|
|
570
|
-
* Parameters.get({
|
|
571
|
-
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
572
|
-
* callback: function(mParams) {
|
|
573
|
-
* // callback is not called, since all Parameters are available synchronously
|
|
574
|
-
* }
|
|
575
|
-
* });
|
|
576
|
-
* // As described above, returns a map with key-value pairs corresponding to the parameters:
|
|
577
|
-
* // mParams = {sapUiParam1: '...value...', sapUiParam2: '...value...', sapUiParam3: '...value...'}
|
|
578
|
-
*
|
|
579
|
-
* @example <caption>Scenario 2: Some Parameters are missing </caption>
|
|
580
|
-
* // "sapUiParam1", "sapUiParam2" are already available
|
|
581
|
-
* // "sapUiParam3" is not yet available
|
|
582
|
-
* Parameters.get({
|
|
583
|
-
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
584
|
-
* callback: function(mParams) {
|
|
585
|
-
* // Parameters.get() callback gets the same map with key-value pairs as in "Scenario 1".
|
|
586
|
-
* // mParams = {sapUiParam1: '...value...', sapUiParam2: '...value...', sapUiParam3: '...value...'}
|
|
587
|
-
* }
|
|
588
|
-
* });
|
|
589
|
-
* // return-value is undefined, since not all Parameters are yet available synchronously
|
|
590
|
-
*
|
|
591
|
-
* @example <caption>Scenario 3: Default values</caption>
|
|
592
|
-
* // Scenario 1 (all parameters are available): the returned parameter map can be used to merge with a map of default values.
|
|
593
|
-
* // Scenario 2 (one or more parameters are missing): the returned undefined value does not change the default parameters
|
|
594
|
-
* // This allows you to always retrieve a consistent set of parameters, either synchronously via the return-value or asynchronously via the provided callback.
|
|
595
|
-
* var mMyParams = Object.assign({
|
|
596
|
-
* sapUiParam1: "1rem",
|
|
597
|
-
* sapUiParam2: "#FF0000",
|
|
598
|
-
* sapUiParam3: "16px"
|
|
599
|
-
* }, Parameters.get({
|
|
600
|
-
* name: ["sapUiParam1", "sapUiParam2", "sapUiParam3"],
|
|
601
|
-
* callback: function(mParams) {
|
|
602
|
-
* // merge the current parameters with the actual parameters in case they are retrieved asynchronously
|
|
603
|
-
* Object.assign(mMyParams, mParams);
|
|
604
|
-
* }
|
|
605
|
-
* }));
|
|
606
|
-
*
|
|
607
|
-
* @param {string | string[] | object} vName the (array with) CSS parameter name(s) or an object containing the (array with) CSS parameter name(s),
|
|
608
|
-
* the scopeElement and a callback for async retrieval of parameters.
|
|
609
|
-
* @param {string | string[]} vName.name the (array with) CSS parameter name(s)
|
|
610
|
-
* @param {sap.ui.core.Element} [vName.scopeElement]
|
|
611
|
-
* Element / control instance to take into account when looking for a parameter value.
|
|
612
|
-
* This can make a difference when a parameter value is overridden in a theme scope set via a CSS class.
|
|
613
|
-
* @param {function(sap.ui.core.theming.Parameters.Value)} [vName.callback] If given, the callback is only executed in case there are still parameters pending and one or more of the requested parameters is missing.
|
|
614
|
-
* @param {sap.ui.core.Element} [oElement]
|
|
615
|
-
* Element / control instance to take into account when looking for a parameter value.
|
|
616
|
-
* This can make a difference when a parameter value is overridden in a theme scope set via a CSS class.
|
|
617
|
-
* @returns {sap.ui.core.theming.Parameters.Value} the CSS parameter value(s) or <code>undefined</code> if the parameters could not be retrieved.
|
|
618
|
-
*
|
|
619
|
-
* @public
|
|
627
|
+
* Parameters.get() without arguments returns
|
|
628
|
+
* copy of complete default parameter set
|
|
629
|
+
* @deprecated As of Version 1.120
|
|
620
630
|
*/
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
631
|
+
if (arguments.length === 0) {
|
|
632
|
+
Log.warning(
|
|
633
|
+
"[FUTURE FATAL] Legacy variant usage of sap.ui.core.theming.Parameters.get API detected. Do not use the Parameters.get() API to retrieve ALL theming parameters, " +
|
|
634
|
+
"as this will lead to unwanted synchronous requests. " +
|
|
635
|
+
"Use the asynchronous API variant instead and retrieve a fixed set of parameters.",
|
|
636
|
+
"LegacyParametersGet",
|
|
637
|
+
"sap.ui.support",
|
|
638
|
+
function() { return { type: "LegacyParametersGet" }; }
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
// retrieve parameters
|
|
642
|
+
// optionally might also trigger a sync JSON request, if a library was loaded but not parsed yet
|
|
643
|
+
var oParams = getParameters();
|
|
644
|
+
return Object.assign({}, oParams["default"]);
|
|
645
|
+
}
|
|
628
646
|
|
|
629
|
-
|
|
647
|
+
if (!vName) {
|
|
648
|
+
return undefined;
|
|
649
|
+
}
|
|
630
650
|
|
|
631
|
-
|
|
632
|
-
|
|
651
|
+
if (vName instanceof Object && !Array.isArray(vName)) {
|
|
652
|
+
// async variant of Parameters.get
|
|
653
|
+
if (!vName.name) {
|
|
654
|
+
future.warningThrows("sap.ui.core.theming.Parameters: Get was called with an object argument without one or more parameter names.");
|
|
655
|
+
return undefined;
|
|
633
656
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
"LegacyParametersGet",
|
|
646
|
-
"sap.ui.support",
|
|
647
|
-
function() { return { type: "LegacyParametersGet" }; }
|
|
648
|
-
);
|
|
649
|
-
|
|
650
|
-
// first try to load all pending parameters
|
|
651
|
-
loadPendingLibraryParameters();
|
|
652
|
-
|
|
653
|
-
// retrieve parameters
|
|
654
|
-
// optionally might also trigger a sync JSON request, if a library was loaded but not parsed yet
|
|
655
|
-
var oParams = getParameters();
|
|
656
|
-
return Object.assign({}, oParams["default"]);
|
|
657
|
+
oElement = vName.scopeElement;
|
|
658
|
+
fnAsyncCallback = vName.callback;
|
|
659
|
+
bParseUrls = vName._restrictedParseUrls || false;
|
|
660
|
+
aNames = typeof vName.name === "string" ? [vName.name] : vName.name;
|
|
661
|
+
bAsync = true;
|
|
662
|
+
} else {
|
|
663
|
+
// legacy variant
|
|
664
|
+
if (typeof vName === "string") {
|
|
665
|
+
aNames = [vName];
|
|
666
|
+
} else { // vName is Array
|
|
667
|
+
aNames = vName;
|
|
657
668
|
}
|
|
658
669
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
670
|
+
Log.warning(
|
|
671
|
+
"[FUTURE FATAL] Legacy variant usage of sap.ui.core.theming.Parameters.get API detected for parameter(s): '" + aNames.join(", ") +
|
|
672
|
+
"'. This could lead to bad performance and additional synchronous XHRs, as parameters might not be available yet. Use asynchronous variant instead.",
|
|
673
|
+
"LegacyParametersGet",
|
|
674
|
+
"sap.ui.support",
|
|
675
|
+
function() { return { type: "LegacyParametersGet" }; }
|
|
676
|
+
);
|
|
677
|
+
}
|
|
662
678
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return undefined;
|
|
668
|
-
}
|
|
669
|
-
oElement = vName.scopeElement;
|
|
670
|
-
fnAsyncCallback = vName.callback;
|
|
671
|
-
bParseUrls = vName._restrictedParseUrls || false;
|
|
672
|
-
aNames = typeof vName.name === "string" ? [vName.name] : vName.name;
|
|
673
|
-
bAsync = true;
|
|
679
|
+
var resolveWithParameter;
|
|
680
|
+
var lookForParameter = function (sName) {
|
|
681
|
+
if (oElement instanceof Element) {
|
|
682
|
+
return getParamForActiveScope(sName, oElement, bAsync);
|
|
674
683
|
} else {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
aNames = [vName];
|
|
678
|
-
} else { // vName is Array
|
|
679
|
-
aNames = vName;
|
|
684
|
+
if (bAsync) {
|
|
685
|
+
parsePendingLibraryParameters();
|
|
680
686
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
"sap.ui.support",
|
|
687
|
-
function() { return { type: "LegacyParametersGet" }; }
|
|
688
|
-
);
|
|
687
|
+
return getParam({
|
|
688
|
+
parameterName: sName,
|
|
689
|
+
loadPendingParameters: !bAsync,
|
|
690
|
+
async: bAsync
|
|
691
|
+
});
|
|
689
692
|
}
|
|
693
|
+
};
|
|
690
694
|
|
|
691
|
-
|
|
692
|
-
var lookForParameter = function (sName) {
|
|
693
|
-
if (oElement instanceof Element) {
|
|
694
|
-
return getParamForActiveScope(sName, oElement, bAsync);
|
|
695
|
-
} else {
|
|
696
|
-
if (bAsync) {
|
|
697
|
-
parsePendingLibraryParameters();
|
|
698
|
-
}
|
|
699
|
-
return getParam({
|
|
700
|
-
parameterName: sName,
|
|
701
|
-
loadPendingParameters: !bAsync,
|
|
702
|
-
async: bAsync
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
const mResult = {};
|
|
695
|
+
const mResult = {};
|
|
708
696
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
697
|
+
for (var i = 0; i < aNames.length; i++) {
|
|
698
|
+
sParamName = aNames[i];
|
|
699
|
+
var sParamValue = lookForParameter(sParamName);
|
|
700
|
+
if (!bAsync || sParamValue) {
|
|
701
|
+
mResult[sParamName] = sParamValue;
|
|
715
702
|
}
|
|
703
|
+
}
|
|
716
704
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (!vParams || (typeof vParams === "object" && (Object.keys(vParams).length !== aNames.length))) {
|
|
726
|
-
Log.error(`sap.ui.core.theming.Parameters: The following parameters could not be found: "${aNames.length === 1 ? aNames[0] : aNames.filter((n) => vParams && !Object.hasOwn(vParams, n))}"`);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
fnAsyncCallback(vParams);
|
|
730
|
-
aCallbackRegistry.splice(aCallbackRegistry.findIndex(findRegisteredCallback), 1);
|
|
731
|
-
}.bind(this);
|
|
705
|
+
if (bAsync && fnAsyncCallback && Object.keys(mResult).length !== aNames.length) {
|
|
706
|
+
resolveWithParameter = function () {
|
|
707
|
+
Theming.detachApplied(resolveWithParameter);
|
|
708
|
+
var vParams = this.get({ // Don't pass callback again
|
|
709
|
+
name: vName.name,
|
|
710
|
+
scopeElement: vName.scopeElement
|
|
711
|
+
});
|
|
732
712
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
if (iIndex >= 0) {
|
|
736
|
-
Theming.detachApplied(aCallbackRegistry[iIndex].eventHandler);
|
|
737
|
-
aCallbackRegistry[iIndex].eventHandler = resolveWithParameter;
|
|
738
|
-
} else {
|
|
739
|
-
aCallbackRegistry.push({ callback: fnAsyncCallback, eventHandler: resolveWithParameter });
|
|
713
|
+
if (!vParams || (typeof vParams === "object" && (Object.keys(vParams).length !== aNames.length))) {
|
|
714
|
+
Log.error(`sap.ui.core.theming.Parameters: The following parameters could not be found: "${aNames.length === 1 ? aNames[0] : aNames.filter((n) => vParams && !Object.hasOwn(vParams, n))}"`);
|
|
740
715
|
}
|
|
741
|
-
Theming.attachApplied(resolveWithParameter);
|
|
742
|
-
return undefined; // Don't return partial result in case we expect applied event.
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// parse CSS URL strings
|
|
746
|
-
// The URLs itself have been resolved at this point
|
|
747
|
-
if (bParseUrls) {
|
|
748
|
-
parseUrls(mResult);
|
|
749
|
-
}
|
|
750
716
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
717
|
+
fnAsyncCallback(vParams);
|
|
718
|
+
aCallbackRegistry.splice(aCallbackRegistry.findIndex(findRegisteredCallback), 1);
|
|
719
|
+
}.bind(this);
|
|
754
720
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
* As with any other <code>Parameters.get()</code> call, a non-existent parameter will result in <code>undefined</code>.
|
|
763
|
-
*
|
|
764
|
-
* Usage in controls:
|
|
765
|
-
*
|
|
766
|
-
* @example <caption>Scenario 4: Parsing CSS URLs</caption>
|
|
767
|
-
* const sUrl = Parameters.get({
|
|
768
|
-
* name: ["sapUiUrlParam"],
|
|
769
|
-
* _restrictedParseUrls: true
|
|
770
|
-
* }) ?? "https://my.bootstrap.url/resource/my/lib/images/fallback.jpeg"; // fallback via nullish coalescing operator
|
|
771
|
-
*
|
|
772
|
-
* @param {object<string,string|undefined>} mParams a set of parameters that should be parsed for CSS URLs
|
|
773
|
-
*/
|
|
774
|
-
function parseUrls(mParams) {
|
|
775
|
-
for (const sKey in mParams) {
|
|
776
|
-
if (Object.hasOwn(mParams, sKey)) {
|
|
777
|
-
let sValue = mParams[sKey];
|
|
778
|
-
const match = rCssUrl.exec(sValue);
|
|
779
|
-
if (match) {
|
|
780
|
-
sValue = match[1];
|
|
781
|
-
} else if (sValue === "''" || sValue === "none") {
|
|
782
|
-
sValue = null;
|
|
783
|
-
}
|
|
784
|
-
mParams[sKey] = sValue;
|
|
785
|
-
}
|
|
721
|
+
// Check if identical callback is already registered and reregister with current parameters
|
|
722
|
+
iIndex = aCallbackRegistry.findIndex(findRegisteredCallback);
|
|
723
|
+
if (iIndex >= 0) {
|
|
724
|
+
Theming.detachApplied(aCallbackRegistry[iIndex].eventHandler);
|
|
725
|
+
aCallbackRegistry[iIndex].eventHandler = resolveWithParameter;
|
|
726
|
+
} else {
|
|
727
|
+
aCallbackRegistry.push({ callback: fnAsyncCallback, eventHandler: resolveWithParameter });
|
|
786
728
|
}
|
|
729
|
+
Theming.attachApplied(resolveWithParameter);
|
|
730
|
+
return undefined; // Don't return partial result in case we expect applied event.
|
|
787
731
|
}
|
|
788
732
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
* @param {Object} mLibraryParameters
|
|
795
|
-
* @private
|
|
796
|
-
*/
|
|
797
|
-
Parameters._setOrLoadParameters = function(mLibraryParameters) {
|
|
733
|
+
// parse CSS URL strings
|
|
734
|
+
// The URLs itself have been resolved at this point
|
|
735
|
+
if (bParseUrls) {
|
|
736
|
+
parseUrls(mResult);
|
|
737
|
+
}
|
|
798
738
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
739
|
+
// if only 1 parameter is requests we unwrap the results array
|
|
740
|
+
return aNames.length === 1 ? mResult[aNames[0]] : mResult;
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Checks the given map of parameters for CSS URLs and parses them to a regular string.
|
|
745
|
+
* Modifies the mParams argument in place.
|
|
746
|
+
*
|
|
747
|
+
* In order to only retrieve resolved URL strings and not the CSS URL strings, we expose a restricted Parameters.get() option <code>_restrictedParseUrls</code>.
|
|
748
|
+
*
|
|
749
|
+
* A URL parameter value of '' (empty string) or "none" (standard CSS value) will result in <code>null</code>.
|
|
750
|
+
* As with any other <code>Parameters.get()</code> call, a non-existent parameter will result in <code>undefined</code>.
|
|
751
|
+
*
|
|
752
|
+
* Usage in controls:
|
|
753
|
+
*
|
|
754
|
+
* @example <caption>Scenario 4: Parsing CSS URLs</caption>
|
|
755
|
+
* const sUrl = Parameters.get({
|
|
756
|
+
* name: ["sapUiUrlParam"],
|
|
757
|
+
* _restrictedParseUrls: true
|
|
758
|
+
* }) ?? "https://my.bootstrap.url/resource/my/lib/images/fallback.jpeg"; // fallback via nullish coalescing operator
|
|
759
|
+
*
|
|
760
|
+
* @param {object<string,string|undefined>} mParams a set of parameters that should be parsed for CSS URLs
|
|
761
|
+
*/
|
|
762
|
+
function parseUrls(mParams) {
|
|
763
|
+
for (const sKey in mParams) {
|
|
764
|
+
if (Object.hasOwn(mParams, sKey)) {
|
|
765
|
+
let sValue = mParams[sKey];
|
|
766
|
+
const match = rCssUrl.exec(sValue);
|
|
767
|
+
if (match) {
|
|
768
|
+
sValue = match[1];
|
|
769
|
+
} else if (sValue === "''" || sValue === "none") {
|
|
770
|
+
sValue = null;
|
|
813
771
|
}
|
|
814
|
-
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Resets the CSS parameters which finally will reload the parameters
|
|
819
|
-
* the next time they are queried via the method <code>get</code>.
|
|
820
|
-
*
|
|
821
|
-
* @public
|
|
822
|
-
* @deprecated As of version 1.92 without a replacement. Application code should
|
|
823
|
-
* not be able to interfere with the automated determination of theme parameters.
|
|
824
|
-
* Resetting the parameters unnecessarily could impact performance. Please use
|
|
825
|
-
* the (potentially async) API to get parameter values and rely on the framework
|
|
826
|
-
* to update parameter values when the theme changes.
|
|
827
|
-
*/
|
|
828
|
-
Parameters.reset = function() {
|
|
829
|
-
this._reset.apply(this, arguments);
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Resets the CSS parameters which finally will reload the parameters
|
|
834
|
-
* the next time they are queried via the method <code>get</code>.
|
|
835
|
-
*
|
|
836
|
-
* @private
|
|
837
|
-
* @ui5-restricted sap.ui.core.theming
|
|
838
|
-
*/
|
|
839
|
-
Parameters._reset = function() {
|
|
840
|
-
// hidden parameter {boolean} bOnlyWhenNecessary
|
|
841
|
-
var bOnlyWhenNecessary = arguments[0] === true;
|
|
842
|
-
if ( !bOnlyWhenNecessary || Theming.getTheme() !== sTheme ) {
|
|
843
|
-
sTheme = Theming.getTheme();
|
|
844
|
-
aParametersToLoad = [];
|
|
845
|
-
mParameters = null;
|
|
772
|
+
mParams[sKey] = sValue;
|
|
846
773
|
}
|
|
847
|
-
}
|
|
848
|
-
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Resets the CSS parameters which finally will reload the parameters
|
|
779
|
+
* the next time they are queried via the method <code>get</code>.
|
|
780
|
+
*
|
|
781
|
+
* @public
|
|
782
|
+
* @deprecated As of version 1.92 without a replacement. Application code should
|
|
783
|
+
* not be able to interfere with the automated determination of theme parameters.
|
|
784
|
+
* Resetting the parameters unnecessarily could impact performance. Please use
|
|
785
|
+
* the (potentially async) API to get parameter values and rely on the framework
|
|
786
|
+
* to update parameter values when the theme changes.
|
|
787
|
+
*/
|
|
788
|
+
Parameters.reset = function() {
|
|
789
|
+
reset(true);
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Resets the CSS parameters which finally will reload the parameters
|
|
794
|
+
* the next time they are queried via the method <code>get</code>.
|
|
795
|
+
*/
|
|
796
|
+
function reset() {
|
|
849
797
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
* @private
|
|
853
|
-
* @param {string} sParamName the theme parameter which contains the logo definition. If nothing is defined the parameter 'sapUiGlobalLogo' is used.
|
|
854
|
-
* @param {boolean} bForce whether a valid URL should be returned even if there is no logo defined.
|
|
798
|
+
* hidden parameter {boolean} bForce
|
|
855
799
|
* @deprecated
|
|
856
800
|
*/
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
801
|
+
const bForce = arguments[0] === true;
|
|
802
|
+
if ( bForce || Theming.getTheme() !== sTheme ) {
|
|
803
|
+
sTheme = Theming.getTheme();
|
|
804
|
+
aParametersToLoad = [...getAllLibraryInfoObjects().keys()];
|
|
805
|
+
mParameters = null;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Helper function to get an image URL based on a given theme parameter.
|
|
811
|
+
*
|
|
812
|
+
* @private
|
|
813
|
+
* @param {string} sParamName the theme parameter which contains the logo definition. If nothing is defined the parameter 'sapUiGlobalLogo' is used.
|
|
814
|
+
* @param {boolean} bForce whether a valid URL should be returned even if there is no logo defined.
|
|
815
|
+
* @deprecated
|
|
816
|
+
*/
|
|
817
|
+
Parameters._getThemeImage = function(sParamName, bForce) {
|
|
818
|
+
sParamName = sParamName || "sapUiGlobalLogo";
|
|
819
|
+
var logo = Parameters.get(sParamName);
|
|
820
|
+
if (logo) {
|
|
821
|
+
var match = rCssUrl.exec(logo);
|
|
822
|
+
if (match) {
|
|
823
|
+
logo = match[1];
|
|
824
|
+
} else if (logo === "''" || logo === "none") {
|
|
825
|
+
logo = null;
|
|
867
826
|
}
|
|
827
|
+
}
|
|
868
828
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
829
|
+
if (bForce && !logo) {
|
|
830
|
+
return sap.ui.require.toUrl('sap/ui/core/themes/base/img/1x1.gif');
|
|
831
|
+
}
|
|
872
832
|
|
|
873
|
-
|
|
874
|
-
|
|
833
|
+
return logo;
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
attachChange(reset);
|
|
875
837
|
|
|
876
838
|
return Parameters;
|
|
877
839
|
|