@openui5/sap.ui.documentation 1.98.0 → 1.101.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 (45) hide show
  1. package/.eslintrc.json +17 -0
  2. package/THIRDPARTY.txt +6 -6
  3. package/package.json +6 -6
  4. package/src/sap/ui/documentation/.library +1 -1
  5. package/src/sap/ui/documentation/TitleLink.js +1 -2
  6. package/src/sap/ui/documentation/library.js +14 -18
  7. package/src/sap/ui/documentation/sdk/Component.js +1 -5
  8. package/src/sap/ui/documentation/sdk/controller/ApiDetail.controller.js +7 -13
  9. package/src/sap/ui/documentation/sdk/controller/ApiDetailIndexDeprecatedExperimental.controller.js +1 -3
  10. package/src/sap/ui/documentation/sdk/controller/ApiMaster.controller.js +0 -2
  11. package/src/sap/ui/documentation/sdk/controller/App.controller.js +1 -3
  12. package/src/sap/ui/documentation/sdk/controller/BaseController.js +1 -1
  13. package/src/sap/ui/documentation/sdk/controller/Code.controller.js +9 -3
  14. package/src/sap/ui/documentation/sdk/controller/ControlsMaster.controller.js +11 -15
  15. package/src/sap/ui/documentation/sdk/controller/Entity.controller.js +1 -2
  16. package/src/sap/ui/documentation/sdk/controller/LiveEditor.controller.js +1 -2
  17. package/src/sap/ui/documentation/sdk/controller/Sample.controller.js +187 -310
  18. package/src/sap/ui/documentation/sdk/controller/SampleBaseController.js +3 -4
  19. package/src/sap/ui/documentation/sdk/controller/SearchPage.controller.js +4 -5
  20. package/src/sap/ui/documentation/sdk/controller/SubApiDetail.controller.js +8 -9
  21. package/src/sap/ui/documentation/sdk/controller/TermsOfUse.controller.js +3 -2
  22. package/src/sap/ui/documentation/sdk/controller/TopicDetail.controller.js +24 -26
  23. package/src/sap/ui/documentation/sdk/controller/TopicDetailInitial.controller.js +2 -2
  24. package/src/sap/ui/documentation/sdk/controller/VersionNotFound.controller.js +2 -0
  25. package/src/sap/ui/documentation/sdk/controller/Welcome.controller.js +3 -3
  26. package/src/sap/ui/documentation/sdk/controller/config/sampleForwardingConfig.js +40 -0
  27. package/src/sap/ui/documentation/sdk/controller/util/ConfigUtil.js +3 -4
  28. package/src/sap/ui/documentation/sdk/controller/util/ControlsInfo.js +7 -6
  29. package/src/sap/ui/documentation/sdk/controller/util/DataTable.js +1 -1
  30. package/src/sap/ui/documentation/sdk/controller/util/DataTableHelper.js +1 -1
  31. package/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js +1 -1
  32. package/src/sap/ui/documentation/sdk/controller/util/ResourceDownloadUtil.js +1 -1
  33. package/src/sap/ui/documentation/sdk/controller/util/datatable/filters/DataTableFilterDropDown.js +0 -2
  34. package/src/sap/ui/documentation/sdk/controller/util/datatable/filters/DataTableFilterRange.js +2 -4
  35. package/src/sap/ui/documentation/sdk/controller/util/overlay/Overlay.js +1 -1
  36. package/src/sap/ui/documentation/sdk/cookieSettingsDialog/controller/CookieSettingsDialog.controller.js +1 -2
  37. package/src/sap/ui/documentation/sdk/index.html +199 -28
  38. package/src/sap/ui/documentation/sdk/model/formatter.js +1 -1
  39. package/src/sap/ui/documentation/sdk/model/libraryData.js +9 -4
  40. package/src/sap/ui/documentation/sdk/util/DocumentationRouter.js +8 -4
  41. package/src/sap/ui/documentation/sdk/util/Resources.js +5 -2
  42. package/src/sap/ui/documentation/sdk/view/Sample.view.xml +2 -2
  43. package/src/sap/ui/documentation/themes/sap_horizon_dark/library.source.less +9 -0
  44. package/src/sap/ui/documentation/themes/sap_horizon_hcb/library.source.less +9 -0
  45. package/src/sap/ui/documentation/themes/sap_horizon_hcw/library.source.less +9 -0
@@ -6,45 +6,47 @@
6
6
 
7
7
 
8
8
  sap.ui.define([
9
- "sap/ui/thirdparty/jquery",
10
- "sap/ui/documentation/sdk/controller/SampleBaseController",
11
- "sap/ui/model/json/JSONModel",
12
- "sap/ui/core/Component",
13
- "sap/ui/core/ComponentContainer",
14
- "sap/ui/documentation/sdk/controller/util/ControlsInfo",
15
- "sap/ui/documentation/sdk/util/ToggleFullScreenHandler",
16
- "sap/m/Text",
17
- "sap/ui/core/HTML",
18
- "sap/m/library",
19
- "sap/base/Log",
9
+ "sap/ui/documentation/sdk/controller/SampleBaseController",
10
+ "sap/ui/model/json/JSONModel",
11
+ "sap/ui/model/resource/ResourceModel",
12
+ "sap/ui/core/Component",
13
+ "sap/ui/core/ComponentContainer",
14
+ "sap/ui/documentation/sdk/controller/util/ControlsInfo",
15
+ "sap/ui/documentation/sdk/util/ToggleFullScreenHandler",
16
+ "sap/m/BusyDialog",
17
+ "sap/m/Text",
18
+ "sap/ui/core/HTML",
19
+ "sap/m/library",
20
+ "sap/base/Log",
20
21
  "sap/base/util/UriParameters",
21
22
  "sap/ui/core/Fragment",
22
- "sap/ui/documentation/sdk/util/Resources"
23
+ "sap/ui/documentation/sdk/util/Resources",
24
+ "./config/sampleForwardingConfig",
25
+ "sap/base/strings/capitalize"
23
26
  ], function(
24
- jQuery,
25
27
  SampleBaseController,
26
28
  JSONModel,
29
+ ResourceModel,
27
30
  Component,
28
31
  ComponentContainer,
29
32
  ControlsInfo,
30
33
  ToggleFullScreenHandler,
34
+ BusyDialog,
31
35
  Text,
32
36
  HTML,
33
37
  mobileLibrary,
34
38
  Log,
35
39
  UriParameters,
36
40
  Fragment,
37
- ResourcesUtil
41
+ ResourcesUtil,
42
+ sampleForwardingConfig,
43
+ capitalize
38
44
  ) {
39
45
  "use strict";
40
46
 
41
47
  // shortcut for sap.m.URLHelper
42
48
  var URLHelper = mobileLibrary.URLHelper;
43
49
 
44
- var COZY = "cozy",
45
- COMPACT = "compact",
46
- CONDENSED = "condensed";
47
-
48
50
  return SampleBaseController.extend("sap.ui.documentation.sdk.controller.Sample", {
49
51
  /* =========================================================== */
50
52
  /* lifecycle methods */
@@ -60,34 +62,18 @@ sap.ui.define([
60
62
  showNewTab: false,
61
63
  rtaLoaded: false
62
64
  });
63
- this._oSampleIframeSettings = {
64
- densityMode: COMPACT,
65
- themeActive: "sap_fiori_3",
66
- rtl: false
67
- };
68
65
 
69
66
  this._sId = null; // Used to hold sample ID
70
67
  this._sEntityId = null; // Used to hold entity ID for the sample currently shown
71
-
72
- // Load runtime authoring asynchronously
73
- if (!ResourcesUtil.getHasProxy()) {
74
- Promise.all([
75
- sap.ui.getCore().loadLibrary("sap.ui.fl", {async: true}),
76
- sap.ui.getCore().loadLibrary("sap.ui.rta", {async: true})
77
- ]).then(function () {
78
- sap.ui.require([
79
- "sap/ui/fl/Utils",
80
- "sap/ui/fl/FakeLrepConnectorLocalStorage",
81
- "sap/ui/core/util/reflection/JsControlTreeModifier"
82
- ], this._loadRTA.bind(this));
83
- }.bind(this));
84
- }
68
+ this.router = this.getRouter();
85
69
 
86
70
  this.getView().setModel(this.oModel);
87
71
 
88
72
  this.bus = sap.ui.getCore().getEventBus();
89
73
  this.setDefaultSampleTheme();
90
74
  this.bus.subscribe("themeChanged", "onDemoKitThemeChanged", this.onDemoKitThemeChanged, this);
75
+
76
+ this.getOwnerComponent()._sSampleIframeOrigin = ResourcesUtil.getConfig() !== "." ? ResourcesUtil.getConfig() : window.origin;
91
77
  },
92
78
 
93
79
  /* =========================================================== */
@@ -104,6 +90,14 @@ sap.ui.define([
104
90
  this._sEntityId = event.getParameter("arguments").entityId;
105
91
 
106
92
  this.byId("page").setBusy(true);
93
+
94
+ if (sampleForwardingConfig[this._sId]) {
95
+ return this.router.navTo("sample", {
96
+ entityId: sampleForwardingConfig[this._sId].entityId,
97
+ sampleId: sampleForwardingConfig[this._sId].sampleId
98
+ }, true);
99
+ }
100
+
107
101
  this.getModel("appView").setProperty("/bHasMaster", false);
108
102
 
109
103
  ControlsInfo.loadData().then(this._loadSample.bind(this));
@@ -152,24 +146,17 @@ sap.ui.define([
152
146
 
153
147
  // set page title
154
148
  oModelData.title = "Sample: " + oSample.name;
155
-
156
- this._createComponent()
157
- .then(function (oComponentContainer) {
149
+ oModelData.showNewTab = true;
150
+ oModelData.id = oSample.id;
151
+ oModelData.name = oSample.name;
152
+ oModelData.details = oSample.details;
153
+ oModelData.description = oSample.description;
154
+ oModelData.showSettings = true;
155
+
156
+ this._createIframe()
157
+ .then(function (oSampleConfig) {
158
158
  // Store a reference to the currently opened sample on the application component
159
- this.getOwnerComponent()._oCurrentOpenedSample = oComponentContainer ? oComponentContainer : undefined;
160
-
161
- //get config
162
- var oComponent = Component.get(oComponentContainer.getComponent());
163
- var oConfig = (oComponent.getMetadata()) ? oComponent.getMetadata().getConfig() : null;
164
- var oSampleConfig = oConfig && oConfig.sample || {};
165
-
166
- // only have the option to run standalone if there is an iframe
167
- oModelData.showNewTab = !!oSampleConfig.iframe || !!ResourcesUtil.getHasProxy();
168
- oModelData.id = oSample.id;
169
- oModelData.name = oSample.name;
170
- oModelData.details = oSample.details;
171
- oModelData.description = oSample.description;
172
- oModelData.showSettings = !!ResourcesUtil.getHasProxy();
159
+ this.getOwnerComponent()._oCurrentOpenedSample = this._oHtmlControl;
173
160
 
174
161
  if (oSampleConfig) {
175
162
 
@@ -188,31 +175,11 @@ sap.ui.define([
188
175
  this._updateFileContent(sRef, sFile);
189
176
  }
190
177
  }
191
-
192
- if (oSampleConfig.iframe || ResourcesUtil.getHasProxy()) {
193
- oComponentContainer = this._createIframe(oComponentContainer, oSampleConfig.iframe);
194
- } else {
195
- this.sIFrameUrl = null;
196
- }
178
+ // Sets the current iframe URL or restores it to "undefined"
179
+ oModelData.iframe = oSampleConfig.iframe;
180
+ oPage.setProperty("enableScrolling", !!oSampleConfig.stretch, true);
197
181
  }
198
182
 
199
- // Sets the current iframe URL or restores it to "undefined"
200
- oModelData.iframe = oSampleConfig.iframe || ResourcesUtil.getHasProxy();
201
-
202
- // handle stretch content
203
- var bStretch = !!oSampleConfig.stretch;
204
- var sHeight = bStretch ? "100%" : null;
205
- oPage.setEnableScrolling(!bStretch);
206
- if (oComponentContainer.setHeight) {
207
- oComponentContainer.setHeight(sHeight);
208
- }
209
- // add content
210
- oPage.removeAllContent();
211
- oPage.addContent(oComponentContainer);
212
-
213
- // scroll to top of page
214
- oPage.scrollTo(0);
215
-
216
183
  this.getAPIReferenceCheckPromise(oSample.entityId).then(function (bHasAPIReference) {
217
184
  this.getView().byId("apiRefButton").setVisible(bHasAPIReference);
218
185
  }.bind(this));
@@ -236,41 +203,59 @@ sap.ui.define([
236
203
  * @public
237
204
  */
238
205
  handleSettings: function () {
239
- var oSampleFrame = this._oHtmlControl.$()[0].contentWindow,
240
- oSampleFrameCore = oSampleFrame.sap.ui.getCore(),
241
- oView;
242
206
 
243
207
  if (!this._oMessageBundle) {
244
- this._oMessageBundle = new oSampleFrame.sap.ui.model.resource.ResourceModel({
208
+ this._oMessageBundle = new ResourceModel({
245
209
  bundleName: "sap.ui.documentation.messagebundle"
246
210
  });
247
211
  }
248
212
 
249
213
  if (!this._oSettingsDialog) {
250
- this._oSettingsDialog = new oSampleFrame.sap.ui.xmlfragment("sap.ui.documentation.sdk.view.appSettingsDialog", this);
214
+ this._oSettingsDialog = sap.ui.xmlfragment("sample", "sap.ui.documentation.sdk.view.appSettingsDialog", this);
251
215
 
252
- oView = oSampleFrameCore.byId("__xmlview0");
253
- oView.setModel(this._oMessageBundle, "i18n");
254
- oView.addDependent(this._oSettingsDialog);
216
+ // oView = sap.ui.getCore().byId("__xmlview0") || sap.ui.getCore().byId("__container0");
217
+ this._oSettingsDialog.setModel(this._oMessageBundle, "i18n");
218
+ // oView.addDependent(this._oSettingsDialog);
255
219
  }
256
220
 
257
- setTimeout(function () {
258
- var oAppSettings = oSampleFrameCore.getConfiguration(),
259
- oThemeSelect = oSampleFrameCore.byId("ThemeSelect"),
260
- sUriParamTheme = UriParameters.fromQuery(window.location.search).get("sap-theme"),
261
- bDensityMode = this._oSampleIframeSettings.densityMode;
221
+ this.loadSampleSettings().then(function() {
222
+ this._oSettingsDialog.open();
223
+ }.bind(this)).catch(function(err) {
224
+ Log.error(err);
225
+ });
226
+ },
262
227
 
263
- // Theme select
264
- oThemeSelect.setSelectedKey(sUriParamTheme ? sUriParamTheme : oAppSettings.getTheme());
228
+ loadSampleSettings: function() {
229
+ return new Promise(function (resolve, reject) {
230
+ var oIframe = this._oHtmlControl.getDomRef();
231
+ oIframe.contentWindow.postMessage({
232
+ type: "SETTINGS",
233
+ reason: "get"
234
+ }, this.getOwnerComponent()._sSampleIframeOrigin);
265
235
 
266
- // RTL
267
- oSampleFrameCore.byId("RTLSwitch").setState(oAppSettings.getRTL());
236
+ window.addEventListener("message", loadSettings);
268
237
 
269
- // Density mode select
270
- oSampleFrameCore.byId("DensityModeSwitch").setSelectedKey(bDensityMode);
238
+ function loadSettings(eMessage) {
239
+ if (eMessage.data.type === "SETTINGS") {
240
+ var oThemeSelect = sap.ui.getCore().byId("sample--ThemeSelect");
271
241
 
272
- this._oSettingsDialog.open();
273
- }.bind(this), 0);
242
+ // Theme select
243
+ oThemeSelect.setSelectedKey(eMessage.data.data.theme);
244
+
245
+ // RTL
246
+ sap.ui.getCore().byId("sample--RTLSwitch").setState(eMessage.data.data.RTL);
247
+
248
+ // Density mode select
249
+ sap.ui.getCore().byId("sample--DensityModeSwitch").setSelectedKey(eMessage.data.data.density.slice(9).toLowerCase());
250
+
251
+ window.removeEventListener("message", loadSettings);
252
+ resolve();
253
+ }
254
+ }
255
+ setTimeout(function() {
256
+ reject("The sample iframe is not loading settings");
257
+ },3000);
258
+ }.bind(this));
274
259
  },
275
260
 
276
261
  /**
@@ -282,22 +267,17 @@ sap.ui.define([
282
267
  },
283
268
 
284
269
  handleSaveAppSettings: function () {
285
- var oSampleFrame = this._oHtmlControl.$()[0].contentWindow,
286
- oSampleFrameCore = oSampleFrame.sap.ui.getCore(),
287
- sDensityMode = oSampleFrameCore.byId("DensityModeSwitch").getSelectedKey(),
288
- sTheme = oSampleFrameCore.byId("ThemeSelect").getSelectedKey(),
289
- bRTL = oSampleFrameCore.byId("RTLSwitch").getState(),
290
- oView = oSampleFrameCore.byId("__xmlview0");
270
+ var sDensityMode = sap.ui.getCore().byId("sample--DensityModeSwitch").getSelectedKey(),
271
+ sTheme = sap.ui.getCore().byId("sample--ThemeSelect").getSelectedKey(),
272
+ bRTL = sap.ui.getCore().byId("sample--RTLSwitch").getState();
291
273
 
292
274
  this._oSettingsDialog.close();
293
275
 
294
276
  // Lazy loading of busy dialog
295
277
  if (!this._oBusyDialog) {
296
- oSampleFrame.sap.ui.require(["sap/m/BusyDialog"], function () {
297
- this._oBusyDialog = new oSampleFrame.sap.m.BusyDialog();
298
- oView.addDependent(this._oBusyDialog);
299
- this._handleBusyDialog();
300
- }.bind(this));
278
+ this._oBusyDialog = new BusyDialog();
279
+ // oView.addDependent(this._oBusyDialog);
280
+ this._handleBusyDialog();
301
281
  } else {
302
282
  this._handleBusyDialog();
303
283
  }
@@ -314,45 +294,16 @@ sap.ui.define([
314
294
  * @private
315
295
  */
316
296
  _applyAppConfiguration: function(sThemeActive, sDensityMode, bRTL){
317
- var oSampleFrame = this._oHtmlControl.$()[0].contentWindow,
318
- oSampleFrameCore = oSampleFrame.sap.ui.getCore();
319
-
320
- if (this._oSampleIframeSettings.densityMode !== sDensityMode) {
321
- this._oSampleIframeSettings.densityMode = sDensityMode;
322
- this._toggleContentDensityClasses(oSampleFrame.jQuery("body"), sDensityMode);
323
- }
324
-
325
- if (this._oSampleIframeSettings.rtl !== bRTL) {
326
- oSampleFrameCore.getConfiguration().setRTL(bRTL);
327
- this._oSampleIframeSettings.rtl = bRTL;
328
- }
329
-
330
- if (oSampleFrameCore.getConfiguration().getTheme() !== sThemeActive) {
331
- oSampleFrameCore.applyTheme(sThemeActive);
332
- this._oSampleIframeSettings.themeActive = sThemeActive;
333
- } else if (this._oSampleIframeSettings.densityMode !== sDensityMode) {
334
- // Notify Core for content density change only if no theme change happened
335
- oSampleFrameCore.notifyContentDensityChanged();
336
- }
337
- },
338
-
339
- /**
340
- * Toggles content density classes in the provided html body
341
- * @param {object} oBody the html body to set the correct class on
342
- * @param {string} sDensityMode content density mode
343
- * @private
344
- */
345
- _toggleContentDensityClasses: function(oBody, sDensityMode){
346
- switch (sDensityMode) {
347
- case COMPACT:
348
- oBody.toggleClass("sapUiSizeCompact", true).toggleClass("sapUiSizeCozy", false).toggleClass("sapUiSizeCondensed", false);
349
- break;
350
- case CONDENSED:
351
- oBody.toggleClass("sapUiSizeCondensed", true).toggleClass("sapUiSizeCozy", false).toggleClass("sapUiSizeCompact", true);
352
- break;
353
- default:
354
- oBody.toggleClass("sapUiSizeCozy", true).toggleClass("sapUiSizeCondensed", false).toggleClass("sapUiSizeCompact", false);
355
- }
297
+ var oIframe = this._oHtmlControl.getDomRef();
298
+ oIframe.contentWindow.postMessage({
299
+ type: "SETTINGS",
300
+ reason: "set",
301
+ data: {
302
+ "density": "sapUiSize" + capitalize(sDensityMode),
303
+ "RTL": bRTL,
304
+ "theme": sThemeActive
305
+ }
306
+ }, this.getOwnerComponent()._sSampleIframeOrigin);
356
307
  },
357
308
 
358
309
  /**
@@ -422,7 +373,7 @@ sap.ui.define([
422
373
  /**
423
374
  * Extends the sSampleId with the relative path defined in sIframePath and returns the resulting path.
424
375
  * @param {string} sSampleId
425
- * @param {string} sIframe
376
+ * @param {string} sIframePath
426
377
  * @returns {string}
427
378
  * @private
428
379
  */
@@ -443,140 +394,93 @@ sap.ui.define([
443
394
  return sSampleId;
444
395
  },
445
396
 
446
- _createIframe : function (oIframeContent, vIframe) {
447
- var sSampleId = this._sId,
397
+ _createIframe : function () {
398
+ return new Promise(function (resolve, reject) {
399
+ var sSampleId = this._sId,
448
400
  sIframePath = "",
449
401
  rExtractFilename = /\/([^\/]*)$/,// extracts everything after the last slash (e.g. some/path/index.html -> index.html)
450
402
  rStripUI5Ending = /\..+$/,// removes everything after the first dot in the filename (e.g. someFile.qunit.html -> .qunit.html)
451
403
  aFileNameMatches,
452
404
  sFileName,
453
- sFileEnding;
454
-
455
- if (typeof vIframe === "string") {
456
- sIframePath = this._resolveIframePath(sSampleId, vIframe);
457
-
458
- // strip the file extension to be able to use jQuery.sap.getModulePath
459
- aFileNameMatches = rExtractFilename.exec(vIframe);
460
- sFileName = (aFileNameMatches && aFileNameMatches.length > 1 ? aFileNameMatches[1] : vIframe);
461
- sFileEnding = rStripUI5Ending.exec(sFileName)[0];
462
- var sIframeWithoutUI5Ending = sFileName.replace(rStripUI5Ending, "");
463
-
464
- // combine namespace with the file name again
465
- this.sIFrameUrl = sap.ui.require.toUrl((sIframePath + "/" + sIframeWithoutUI5Ending).replace(/\./g, "/")) + sFileEnding || ".html";
466
- } else if (ResourcesUtil.getHasProxy()) {
467
- var sSamplePath = ResourcesUtil.getResourceOriginPath(sap.ui.require.toUrl(this._sId.replace(/\./g, "/"))),
468
- sSampleOrigin = (window['sap-ui-documentation-config'] && window['sap-ui-documentation-config'].demoKitResourceOrigin) || "",
469
- sSampleVersion = ResourcesUtil.getResourcesVersion();
405
+ sFileEnding,
406
+ vIframe;
470
407
 
471
- this.sIFrameUrl =
472
- "resources/sap/ui/documentation/sdk/index.html" +
473
- "?sap-ui-xx-sample-id=" + sSampleId
474
- + "&&sap-ui-xx-sample-path=" + sSamplePath
475
- + "&&sap-ui-xx-sample-origin=" + sSampleOrigin
476
- + "&&sap-ui-xx-sample-version=" + sSampleVersion;
477
- } else {
478
- Log.error("no iframe source was provided");
479
- return;
480
- }
481
-
482
- if (!this._oHtmlControl) {
483
- var oComponent = this.getOwnerComponent();
484
-
485
- // Guarantees the sample initially to have the same content density, as the whole Demo Kit
486
- switch (oComponent.getContentDensityClass()) {
487
- case "sapUiSizeCompact":
488
- this._oSampleIframeSettings.densityMode = COMPACT;
489
- break;
490
- case "sapUiSizeCondensed":
491
- this._oSampleIframeSettings.densityMode = CONDENSED;
492
- break;
493
- default:
494
- this._oSampleIframeSettings.densityMode = COZY;
495
- }
408
+ this.fResolve = resolve;
409
+ this.fReject = reject;
410
+ var sSampleOrigin = (window['sap-ui-documentation-config'] && window['sap-ui-documentation-config'].demoKitResourceOrigin) || "",
411
+ sSampleVersion = ResourcesUtil.getResourcesVersion();
496
412
 
497
- this._oHtmlControl = new HTML({
498
- id : "sampleFrame",
499
- content : '<iframe src="' + this.sIFrameUrl + '" id="sampleFrame" frameBorder="0"></iframe>'
500
- }).addEventDelegate({
501
- onAfterRendering : function () {
502
-
503
- // Do not attach on "load" event on every onAfterRendering of the HTML control
504
- if (!this._oHtmlControl._jQueryHTMLControlLoadEventAttached) {
505
- this._oHtmlControl.$().on("load", function () {
506
- var oSampleFrame = this._oHtmlControl.$()[0].contentWindow,
507
- oSampleFrameCore = oSampleFrame.sap.ui.getCore(),
508
- oFrame = document.getElementById("sampleFrame");
509
-
510
- this._oMessageBundle = null;
511
- this._oSettingsDialog = null;
512
- this._oBusyDialog = null;
513
-
514
- if (this.oModel.getData().iframe) {
515
- Promise.all([
516
- oSampleFrameCore.loadLibrary("sap.ui.fl", {async: true}),
517
- oSampleFrameCore.loadLibrary("sap.ui.rta", {async: true})
518
- ]).then(function () {
519
- oSampleFrame.sap.ui.require([
520
- "sap/ui/fl/Utils",
521
- "sap/ui/fl/FakeLrepConnectorLocalStorage",
522
- "sap/ui/core/util/reflection/JsControlTreeModifier"
523
- ], this._loadRTA.bind(this));
524
- }.bind(this));
525
-
526
-
527
- oFrame.onToggleAdaptationMode = function () {
528
- oSampleFrame.sap.ui.require([
529
- "sap/ui/rta/api/startKeyUserAdaptation"
530
- ], function (
531
- startKeyUserAdaptation
532
- ) {
533
- if (!this._oRTA) {
534
- var oContainer = oSampleFrameCore.byId("__container0");
535
-
536
- startKeyUserAdaptation({
537
- rootControl : oContainer.getComponentInstance()
538
- }).then(function(oRta) {
539
- this._oRTA = oRta;
540
- oContainer.$().css({"padding-top": "2.5rem", "box-sizing": "border-box"});
541
- this._oRTA.attachStop(function () {
542
- oContainer.$().css({"padding-top": "0", "box-sizing": "content-box"});
543
- this._oRTA.destroy();
544
- delete this._oRTA;
545
- }.bind(this));
546
- }.bind(this));
547
- }
548
- }.bind(this));
549
- };
413
+ this.sIFrameUrl = ResourcesUtil.getResourceOrigin() +
414
+ "/resources/sap/ui/documentation/sdk/index.html" +
415
+ (new URL(document.location.href).search ? new URL(document.location.href).search + "&" : "?") +
416
+ "sap-ui-xx-sample-id=" + sSampleId
417
+ + "&sap-ui-xx-sample-origin=" + sSampleOrigin + sSampleVersion
418
+ + "&sap-ui-xx-dk-origin=" + window.location.origin;
419
+
420
+ if (!this._oHtmlControl) {
421
+
422
+ var fnMessage = function (eMessage) {
423
+ if (eMessage.data.type === "INIT") {
424
+ var oConfiguration = sap.ui.getCore().getConfiguration();
425
+ if (eMessage.data.config && eMessage.data.config.sample && eMessage.data.config.sample.iframe) {
426
+ sSampleId = this._sId;
427
+ vIframe = eMessage.data.config.sample.iframe;
428
+ sIframePath = this._resolveIframePath(sSampleId, vIframe);
429
+
430
+ //vlaid only for samples that contains own index.html
431
+ // strip the file extension to be able to use jQuery.sap.getModulePath
432
+ aFileNameMatches = rExtractFilename.exec(vIframe);
433
+ sFileName = (aFileNameMatches && aFileNameMatches.length > 1 ? aFileNameMatches[1] : vIframe);
434
+ sFileEnding = rStripUI5Ending.exec(sFileName)[0];
435
+ var sIframeWithoutUI5Ending = sFileName.replace(rStripUI5Ending, "");
436
+
437
+ // combine namespace with the file name again
438
+ this.sIFrameUrl = (sap.ui.require.toUrl((sIframePath + "/" + sIframeWithoutUI5Ending).replace(/\./g, "/")) + sFileEnding || ".html")
439
+ + "?sap-ui-theme=" + sap.ui.getCore().getConfiguration().getTheme();
440
+ this._oHtmlControl.getDomRef().src = this.sIFrameUrl;
441
+ }
442
+ this._oHtmlControl.getDomRef().contentWindow.postMessage({
443
+ type: "SETTINGS",
444
+ reason: "set",
445
+ data: {
446
+ "density": this.getOwnerComponent().getContentDensityClass(),
447
+ "RTL": oConfiguration.getRTL(),
448
+ "theme": oConfiguration.getTheme()
550
449
  }
551
-
552
- // Apply theme settings to iframe sample
553
- oSampleFrame.sap.ui.getCore().attachInit(function () {
554
- oSampleFrameCore.applyTheme(ResourcesUtil.getHasProxy() ?
555
- this._oSampleIframeSettings.themeActive : this._oCore.getConfiguration().getTheme());
556
- oSampleFrameCore.getConfiguration().setRTL(ResourcesUtil.getHasProxy() ?
557
- this._oSampleIframeSettings.rtl : this._oCore.getConfiguration().getRTL());
558
- this._toggleContentDensityClasses(oSampleFrame.jQuery('body'), this._oSampleIframeSettings.densityMode);
559
-
560
- // Notify Core for content density change
561
- oSampleFrameCore.notifyContentDensityChanged();
562
- }.bind(this));
563
- }.bind(this));
564
-
565
- this._oHtmlControl._jQueryHTMLControlLoadEventAttached = true;
450
+ }, this.getOwnerComponent()._sSampleIframeOrigin);
451
+ this.fResolve(eMessage.data.config.sample);
452
+ } else if (eMessage.data.type === "ERR") {
453
+ this.fReject(eMessage.data.data.msg);
454
+ } else if (eMessage.data.type === "RTA") {
455
+ this._loadRTA.call(this);
566
456
  }
457
+ }.bind(this);
458
+
459
+ this._oHtmlControl = new HTML({
460
+ id : "sampleFrame",
461
+ content : '<iframe src="' + this.sIFrameUrl + '" id="sampleFrame" frameBorder="0"></iframe>'
462
+ }).addEventDelegate({
463
+ onBeforeRendering: function () {
464
+ window.removeEventListener("message", fnMessage);
465
+ }
466
+ })
467
+ .addEventDelegate({
468
+ onAfterRendering: function () {
469
+ window.addEventListener("message", fnMessage);
470
+ }
471
+ });
472
+ } else {
473
+ // If we already have the control just navigate to the new URL
474
+ this._oHtmlControl.getDomRef().src = this.sIFrameUrl;
475
+ }
476
+ this.byId("page").removeAllContent();
477
+ this.byId("page").addContent(this._oHtmlControl);
567
478
 
568
- }.bind(this)
569
- });
570
- } else {
571
- // If we already have the control just navigate to the new URL
572
- this._oHtmlControl.getDomRef().src = this.sIFrameUrl;
573
- }
574
-
575
- return this._oHtmlControl;
576
-
479
+ }.bind(this));
577
480
  },
578
481
 
579
482
  _createComponent : function () {
483
+
580
484
  // create component only once
581
485
  var sCompId = 'sampleComp-' + this._sId;
582
486
  var sCompName = this._sId;
@@ -605,10 +509,10 @@ sap.ui.define([
605
509
  },
606
510
 
607
511
  onDemoKitThemeChanged: function(sChannelId, sEventId, oData) {
608
- if (this._oHtmlControl && !ResourcesUtil.getHasProxy()) {
609
- this._oHtmlControl.$()[0].contentWindow.sap.ui.getCore().applyTheme(oData.sThemeActive);
512
+ if (this._oHtmlControl && this.getModel().getProperty("/iframe")) {
513
+ this._applySearchParamValueToIframeURL("sap-ui-theme", oData.sThemeActive);
514
+ this._oHtmlControl.getDomRef().src = this.sIFrameUrl;
610
515
  }
611
- this.setDefaultSampleTheme();
612
516
  },
613
517
 
614
518
  onNavBack : function (oEvt) {
@@ -646,24 +550,9 @@ sap.ui.define([
646
550
  this.sIFrameUrl = this.sIFrameUrl + decodeURI(oIFrameURL.search);
647
551
  },
648
552
 
649
- _loadRTA: function (
650
- Utils,
651
- FakeLrepConnectorLocalStorage,
652
- JsControlTreeModifier
653
- ) {
553
+ _loadRTA: function () {
654
554
  var oModelData = this.oModel.getData();
655
555
 
656
- // fake stable IDs
657
- JsControlTreeModifier.checkControlId = function () {
658
- return true;
659
- };
660
- Utils.checkControlId = function() {
661
- return true;
662
- };
663
-
664
- FakeLrepConnectorLocalStorage.enableFakeConnector({
665
- "isProductiveSystem": true
666
- });
667
556
  oModelData.rtaLoaded = true;
668
557
 
669
558
  this.oModel.setData(oModelData);
@@ -677,29 +566,17 @@ sap.ui.define([
677
566
  },
678
567
 
679
568
  onToggleAdaptationMode : function (oEvt) {
680
- if (this.oModel.getData().iframe) {
681
- window.document.getElementsByTagName("iframe")[0].onToggleAdaptationMode();
682
- return;
569
+ if (!this._oHtmlControl || !this._oHtmlControl.getDomRef()) {
570
+ return false;
683
571
  }
684
- sap.ui.require([
685
- "sap/ui/rta/api/startKeyUserAdaptation"
686
- ], function (
687
- startKeyUserAdaptation
688
- ) {
689
- if (!this._oRTA) {
690
- var oContainer = this.byId("page").getContent()[0];
691
-
692
- startKeyUserAdaptation({
693
- rootControl : oContainer.getComponentInstance()
694
- }).then(function(oRta) {
695
- this._oRTA = oRta;
696
- this._oRTA.attachStop(function () {
697
- this._oRTA.destroy();
698
- delete this._oRTA;
699
- }.bind(this));
700
- }.bind(this));
572
+
573
+ var oIframe = this._oHtmlControl.getDomRef();
574
+ oIframe.contentWindow.postMessage({
575
+ type: "RTA",
576
+ data: {
577
+ "msg": "Start the RTA"
701
578
  }
702
- }.bind(this));
579
+ }, this.getOwnerComponent()._sSampleIframeOrigin);
703
580
  },
704
581
 
705
582
  onRouteNotFound: function() {