@openui5/sap.ui.documentation 1.120.10 → 1.121.1
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/.reuse/dep5 +23 -21
- package/THIRDPARTY.txt +6 -43
- package/package.json +7 -7
- package/src/sap/ui/documentation/.library +3 -9
- package/src/sap/ui/documentation/DemoAppsCardHeader.js +62 -0
- package/src/sap/ui/documentation/DemokitTreeItem.js +1 -0
- package/src/sap/ui/documentation/DemokitTreeItemRenderer.js +20 -13
- package/src/sap/ui/documentation/ParamText.js +2 -1
- package/src/sap/ui/documentation/library.js +23 -10
- package/src/sap/ui/documentation/messagebundle.properties +20 -20
- package/src/sap/ui/documentation/messagebundle_ar.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_bg.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_ca.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_cnr.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_cs.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_cy.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_da.properties +12 -12
- package/src/sap/ui/documentation/messagebundle_de.properties +16 -16
- package/src/sap/ui/documentation/messagebundle_el.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_en.properties +398 -10
- package/src/sap/ui/documentation/messagebundle_en_GB.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_en_US_sappsd.properties +2 -2
- package/src/sap/ui/documentation/messagebundle_en_US_saprigi.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_en_US_saptrc.properties +2 -2
- package/src/sap/ui/documentation/messagebundle_es.properties +11 -11
- package/src/sap/ui/documentation/messagebundle_es_MX.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_et.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_fi.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_fr.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_fr_CA.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_hi.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_hr.properties +11 -11
- package/src/sap/ui/documentation/messagebundle_hu.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_id.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_it.properties +11 -11
- package/src/sap/ui/documentation/messagebundle_iw.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_ja.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_kk.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_ko.properties +11 -11
- package/src/sap/ui/documentation/messagebundle_lt.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_lv.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_mk.properties +15 -15
- package/src/sap/ui/documentation/messagebundle_ms.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_nl.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_no.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_pl.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_pt.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_pt_PT.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_ro.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_ru.properties +12 -12
- package/src/sap/ui/documentation/messagebundle_sh.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_sk.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_sl.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_sr.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_sv.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_th.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_tr.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_uk.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_vi.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_zh_CN.properties +10 -10
- package/src/sap/ui/documentation/messagebundle_zh_TW.properties +10 -10
- package/src/sap/ui/documentation/sdk/controller/ApiMaster.controller.js +40 -30
- package/src/sap/ui/documentation/sdk/controller/App.controller.js +20 -12
- package/src/sap/ui/documentation/sdk/controller/ControlsMaster.controller.js +3 -3
- package/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js +208 -459
- package/src/sap/ui/documentation/sdk/controller/LiveEditor.controller.js +9 -8
- package/src/sap/ui/documentation/sdk/controller/News.controller.js +3 -3
- package/src/sap/ui/documentation/sdk/controller/ReleaseNotes.controller.js +13 -12
- package/src/sap/ui/documentation/sdk/controller/Sample.controller.js +24 -18
- package/src/sap/ui/documentation/sdk/controller/SubApiDetail.controller.js +18 -1
- package/src/sap/ui/documentation/sdk/controller/util/APIInfo.js +3 -1
- package/src/sap/ui/documentation/sdk/controller/util/ControlsInfo.js +2 -1
- package/src/sap/ui/documentation/sdk/controller/util/NewsInfo.js +3 -3
- package/src/sap/ui/documentation/sdk/controller/util/ThemePicker.js +5 -3
- package/src/sap/ui/documentation/sdk/controller/util/URLUtil.js +16 -16
- package/src/sap/ui/documentation/sdk/cookieSettingsDialog/controller/CookieSettingsDialog.controller.js +8 -8
- package/src/sap/ui/documentation/sdk/images/DemoApps_intro_card.svg +8 -0
- package/src/sap/ui/documentation/sdk/index.js +1 -1
- package/src/sap/ui/documentation/sdk/model/formatter.js +323 -291
- package/src/sap/ui/documentation/sdk/model/libraryData.js +9 -26
- package/src/sap/ui/documentation/sdk/thirdparty/highlight.js/highlight.js +14905 -8737
- package/src/sap/ui/documentation/sdk/util/DocumentationRouter.js +6 -3
- package/src/sap/ui/documentation/sdk/view/AboutDialog.fragment.xml +1 -1
- package/src/sap/ui/documentation/sdk/view/ApiMaster.view.xml +31 -28
- package/src/sap/ui/documentation/sdk/view/App.view.xml +5 -4
- package/src/sap/ui/documentation/sdk/view/DemoApps.view.xml +189 -141
- package/src/sap/ui/documentation/sdk/view/SubApiDetail.view.xml +34 -30
- package/src/sap/ui/documentation/sdk/view/Tools.view.xml +2 -2
- package/src/sap/ui/documentation/themes/base/DemoApps.less +180 -0
- package/src/sap/ui/documentation/themes/base/DemokitTreeItem.less +20 -0
- package/src/sap/ui/documentation/themes/base/Documentation.less +6 -8
- package/src/sap/ui/documentation/themes/base/Search.less +1 -1
- package/src/sap/ui/documentation/themes/base/library.source.less +3 -2
- package/src/sap/ui/documentation/themes/sap_horizon_hcb/DemoApps.less +11 -0
- package/src/sap/ui/documentation/themes/sap_horizon_hcb/library.source.less +3 -1
- package/src/sap/ui/documentation/themes/sap_horizon_hcw/DemoApps.less +30 -0
- package/src/sap/ui/documentation/themes/sap_horizon_hcw/library.source.less +3 -1
- package/LICENSES/BSD-2-Clause.txt +0 -22
- package/src/sap/ui/documentation/sdk/images/DemoApps_M_and_L_cropped.jpg +0 -0
- package/src/sap/ui/documentation/sdk/images/DemoApps_S_cropped.jpg +0 -0
- package/src/sap/ui/documentation/sdk/thirdparty/esprima.js +0 -3756
- package/src/sap/ui/documentation/sdk/view/BlockLayoutCell.fragment.xml +0 -56
- package/src/sap/ui/documentation/sdk/view/BlockLayoutTeaserCell.fragment.xml +0 -60
|
@@ -5,468 +5,217 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
sap.ui.define([
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Registers an event listener on device resize
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
_registerResize: function () {
|
|
124
|
-
Device.media.attachHandler(this._onResize, this);
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Deregisters the event listener for device resize
|
|
129
|
-
* @private
|
|
130
|
-
*/
|
|
131
|
-
_deregisterResize: function () {
|
|
132
|
-
Device.media.detachHandler(this._onResize, this);
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Switches the maximum height of the phone image for optimal display in landscape mode
|
|
137
|
-
* @param {sap.ui.base.Event} oEvent Device orientation change event
|
|
138
|
-
* @private
|
|
139
|
-
*/
|
|
140
|
-
_onOrientationChange: function(oEvent) {
|
|
141
|
-
this.byId("phoneImage").toggleStyleClass("phoneHeaderImageLandscape", oEvent.landscape);
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Switches the image to phone and hides the download icon when decreasing the window size
|
|
146
|
-
* @param {sap.ui.base.Event} oEvent Device media change event
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
_onResize: function(oEvent) {
|
|
150
|
-
this.byId("phoneImage").setVisible(oEvent.name === "Phone");
|
|
151
|
-
this.byId("desktopImage").setVisible(oEvent.name !== "Phone");
|
|
152
|
-
this.byId("phoneImage").toggleStyleClass("phoneHeaderImageDesktop", oEvent.name === "Phone");
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Handles "demoapps" routing
|
|
157
|
-
* @function
|
|
158
|
-
* @private
|
|
159
|
-
*/
|
|
160
|
-
_onMatched: function () {
|
|
161
|
-
try {
|
|
162
|
-
this.hideMasterSide();
|
|
163
|
-
} catch (e) {
|
|
164
|
-
// try-catch due to a bug in UI5 SplitApp, CL 1898264 should fix it
|
|
165
|
-
Log.error(e);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Opens the download dialog
|
|
171
|
-
* @param {sap.ui.base.Event} oEvent the Button press event
|
|
172
|
-
* @public
|
|
173
|
-
*/
|
|
174
|
-
onDownloadButtonPress: function (oEvent) {
|
|
175
|
-
var oDownloadDialog = this.byId("downloadDialog"),
|
|
176
|
-
oDownloadDialogList = this.byId("downloadDialogList");
|
|
177
|
-
this._oDownloadButton = oEvent.getSource();
|
|
178
|
-
|
|
179
|
-
oDownloadDialogList.getBinding("items").filter([]);
|
|
180
|
-
oDownloadDialog.open();
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Opens more information about Demo Apps
|
|
185
|
-
* @public
|
|
186
|
-
*/
|
|
187
|
-
onReadMoreButtonPress: function () {
|
|
188
|
-
var sLink = formatter.formatHttpHrefForNewWindow(this.getModel("newWindowLinks").getProperty("/demoAppsHomeLink"));
|
|
189
|
-
window.open(sLink, "_blank");
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Filters the download dialog
|
|
194
|
-
* @param {sap.ui.base.Event} oEvent the SearchField liveChange event
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
197
|
-
onSearch: function (oEvent) {
|
|
198
|
-
var oDownloadDialogList = this.byId("downloadDialogList"),
|
|
199
|
-
sQuery = oEvent.getParameter("newValue");
|
|
200
|
-
|
|
201
|
-
oDownloadDialogList.getBinding("items").filter([
|
|
202
|
-
new Filter("name", FilterOperator.Contains, sQuery)
|
|
203
|
-
]);
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
onCloseDialog: function() {
|
|
207
|
-
var oDownloadDialog = this.byId("downloadDialog"),
|
|
208
|
-
oDownloadDialogSearch = this.byId("downloadDialogSearch");
|
|
209
|
-
|
|
210
|
-
oDownloadDialog.close();
|
|
211
|
-
oDownloadDialogSearch.setValue("");
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Downloads a demo app
|
|
216
|
-
* @param {sap.ui.base.Event} oEvent the Button press event
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
onDownloadPress: function (oEvent) {
|
|
220
|
-
var oSelectedItem = oEvent.getParameters().selectedItem,
|
|
221
|
-
oListItem = oSelectedItem ? oSelectedItem : oEvent.getSource().getParent();
|
|
222
|
-
|
|
223
|
-
this._oDownloadButton.setBusy(true);
|
|
224
|
-
sap.ui.require([
|
|
225
|
-
"sap/ui/core/util/File",
|
|
226
|
-
"sap/ui/thirdparty/jszip"
|
|
227
|
-
], function (File, JSZip) {
|
|
228
|
-
var oZipFile = new JSZip();
|
|
229
|
-
|
|
230
|
-
// load the config file from the custom data attached to the list item
|
|
231
|
-
jQuery.getJSON(oListItem.data("config"), function (oConfig) {
|
|
232
|
-
var aFiles = oConfig.files,
|
|
233
|
-
aPromises = [],
|
|
234
|
-
aFails = [];
|
|
235
|
-
|
|
236
|
-
// add extra download files
|
|
237
|
-
aFiles.forEach(function(sFilePath) {
|
|
238
|
-
var oPromise = ResourceDownloadUtil.fetch(oConfig.cwd + sFilePath);
|
|
239
|
-
|
|
240
|
-
oPromise.then(function (oContent) {
|
|
241
|
-
if (oContent.errorMessage) {
|
|
242
|
-
// promise gets resolved in error case since Promise.all will not wait for all fails
|
|
243
|
-
aFails.push(oContent.errorMessage);
|
|
244
|
-
} else {
|
|
245
|
-
// exclude relative paths outside of the app root (e.g. common helpers, images, ...)
|
|
246
|
-
if (!sFilePath.startsWith("../")) {
|
|
247
|
-
oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
aPromises.push(oPromise);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// add generic license file
|
|
255
|
-
var sUrl = sap.ui.require.toUrl("LICENSE.txt").replace("resources/", "");
|
|
256
|
-
var oLicensePromise = ResourceDownloadUtil.fetch(sUrl);
|
|
257
|
-
var oLicensePromiseWrapper = new Promise(function(resolve, reject) {
|
|
258
|
-
oLicensePromise.then(function (oContent) {
|
|
259
|
-
oZipFile.file("LICENSE.txt", oContent);
|
|
260
|
-
resolve();
|
|
261
|
-
}).catch(function() {
|
|
262
|
-
// LICENSE.txt not available in SAPUI5, continue without it
|
|
263
|
-
resolve();
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
aPromises.push(oLicensePromiseWrapper);
|
|
268
|
-
|
|
269
|
-
Promise.all(aPromises).then(function () {
|
|
270
|
-
// collect errors and show them
|
|
271
|
-
if (aFails.length) {
|
|
272
|
-
var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
|
|
273
|
-
return sErrorMessage + sError + "\n";
|
|
274
|
-
}, "Could not locate the following download files:\n");
|
|
275
|
-
this._handleError(sCompleteErrorMessage);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// show success message
|
|
279
|
-
this._oDownloadButton.setBusy(false);
|
|
280
|
-
MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
|
|
281
|
-
|
|
282
|
-
// still make the available files ready for download
|
|
283
|
-
var oContent = oZipFile.generate({type:"blob"});
|
|
284
|
-
this._createArchive(File, oContent, oListItem.getLabel());
|
|
285
|
-
}.bind(this));
|
|
286
|
-
}.bind(this));
|
|
8
|
+
"sap/base/Log",
|
|
9
|
+
"sap/m/MessageToast",
|
|
10
|
+
"sap/m/MessageBox",
|
|
11
|
+
"sap/ui/documentation/sdk/controller/BaseController",
|
|
12
|
+
"sap/ui/documentation/sdk/controller/util/ResourceDownloadUtil",
|
|
13
|
+
"sap/ui/documentation/sdk/model/formatter",
|
|
14
|
+
"sap/ui/documentation/sdk/model/libraryData",
|
|
15
|
+
"sap/ui/model/json/JSONModel",
|
|
16
|
+
"sap/ui/core/util/File",
|
|
17
|
+
"sap/ui/thirdparty/jszip",
|
|
18
|
+
"sap/ui/util/openWindow"
|
|
19
|
+
], function (Log, MessageToast, MessageBox, BaseController, ResourceDownloadUtil, formatter, libraryData, JSONModel, File, JSZip, openWindow) {
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
return BaseController.extend("sap.ui.documentation.sdk.controller.DemoApps", {
|
|
23
|
+
|
|
24
|
+
formatter: formatter,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Called when the controller is instantiated.
|
|
28
|
+
*/
|
|
29
|
+
onInit: function () {
|
|
30
|
+
BaseController.prototype.onInit.call(this);
|
|
31
|
+
|
|
32
|
+
this.processDemoAppsData();
|
|
33
|
+
|
|
34
|
+
this.getRouter().getRoute("demoapps").attachPatternMatched(this.onPatternMatched, this);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Processes the demo apps data.
|
|
39
|
+
*/
|
|
40
|
+
processDemoAppsData: function() {
|
|
41
|
+
libraryData.getDemoAppsData().then(function (aDemoApps) {
|
|
42
|
+
aDemoApps = this.flattenDemoAppsCategories(aDemoApps);
|
|
43
|
+
|
|
44
|
+
var oModel = new JSONModel(aDemoApps);
|
|
45
|
+
this.setModel(oModel);
|
|
46
|
+
|
|
47
|
+
this.addCategoryClassToGridItems("sapUiDemoKitDemoAppsMainContent");
|
|
48
|
+
}.bind(this));
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flattens the demo apps by category.
|
|
53
|
+
* @param {object} data - The demo apps data.
|
|
54
|
+
* @returns {object} The flattened demo apps data.
|
|
55
|
+
*/
|
|
56
|
+
flattenDemoAppsCategories(data) {
|
|
57
|
+
data.demoAppsByCategory.forEach(function(category) {
|
|
58
|
+
category.rows = [].concat.apply([], category.rows);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return data;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Adds category class to each grid item.
|
|
66
|
+
* @param {string} gridId - The ID of the grid.
|
|
67
|
+
*/
|
|
68
|
+
addCategoryClassToGridItems(gridId) {
|
|
69
|
+
this.byId(gridId).getItems().forEach(function(gridItem) {
|
|
70
|
+
var cssClass = gridItem.data("demo-apps-category");
|
|
71
|
+
gridItem.addStyleClass(cssClass);
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Creates an archive file and triggers a download.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} oContent the blob for the zip file
|
|
79
|
+
* @param {string} sFilename the file name
|
|
80
|
+
*/
|
|
81
|
+
createArchive: function (oContent, sFilename) {
|
|
82
|
+
File.save(oContent, sFilename, "zip", "application/zip");
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Handles the pattern matched event.
|
|
87
|
+
* Currently, it hides the master side of the UI.
|
|
88
|
+
*/
|
|
89
|
+
onPatternMatched: function () {
|
|
90
|
+
this.hideMasterSide();
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Opens a new window with the demo apps home link.
|
|
95
|
+
*/
|
|
96
|
+
onReadMoreButtonPress: function () {
|
|
97
|
+
var sDemoAppsReadMoreLink = "topic/a3ab54ecf7ac493b91904beb2095d208",
|
|
98
|
+
sFormattedLink = formatter.formatHttpHrefForNewWindow(sDemoAppsReadMoreLink);
|
|
99
|
+
|
|
100
|
+
openWindow(sFormattedLink, "_blank");
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handles the download press event.
|
|
105
|
+
*
|
|
106
|
+
* @param {object} oEvent - The event object.
|
|
107
|
+
*/
|
|
108
|
+
onDownloadPress: function (oEvent) {
|
|
109
|
+
var oListItem = oEvent.getSource().getParent();
|
|
110
|
+
|
|
111
|
+
fetch(oListItem.data("config"))
|
|
112
|
+
.then(function (response) {
|
|
113
|
+
return response.json();
|
|
114
|
+
})
|
|
115
|
+
.then(this.processFiles.bind(this, oListItem))
|
|
116
|
+
.catch(function (error) {
|
|
117
|
+
Log.error('Error: ', error);
|
|
118
|
+
this.handleError('An error occurred: ' + error.message);
|
|
287
119
|
}.bind(this));
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Processes the files for the list item.
|
|
124
|
+
*
|
|
125
|
+
* @param {object} oListItem - The list item.
|
|
126
|
+
* @param {object} oConfig - The app configuration.
|
|
127
|
+
*/
|
|
128
|
+
processFiles: function (oListItem, oConfig) {
|
|
129
|
+
var aFails = [],
|
|
130
|
+
aPromises = [],
|
|
131
|
+
oZipFile = new JSZip(),
|
|
132
|
+
aFiles = oConfig.files;
|
|
133
|
+
|
|
134
|
+
aFiles.forEach(function (sFilePath) {
|
|
135
|
+
var oPromise = this.handleFilePromise(sFilePath, oZipFile, aFails, oConfig);
|
|
136
|
+
aPromises.push(oPromise);
|
|
137
|
+
}.bind(this));
|
|
138
|
+
|
|
139
|
+
this.addLicenseFileToZip(aPromises, oZipFile);
|
|
140
|
+
this.handlePromisesCompletion(aPromises, aFails, oZipFile, oListItem);
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Handles the file promise.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} sFilePath - The file path.
|
|
147
|
+
* @param {object} oZipFile - The zip file.
|
|
148
|
+
* @param {Array} aFails - The array of failed promises.
|
|
149
|
+
* @param {object} oConfig - The configuration.
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise} A promise that resolves with the file.
|
|
152
|
+
*/
|
|
153
|
+
handleFilePromise: function (sFilePath, oZipFile, aFails, oConfig) {
|
|
154
|
+
var oPromise = ResourceDownloadUtil.fetch(oConfig.cwd + sFilePath);
|
|
155
|
+
|
|
156
|
+
oPromise.then(function (oContent) {
|
|
157
|
+
if (oContent.errorMessage) {
|
|
158
|
+
aFails.push(oContent.errorMessage);
|
|
159
|
+
} else if (!sFilePath.startsWith("../")) {
|
|
160
|
+
oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
|
|
309
161
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
createDemoAppCellFactory: function (_, oBindingContext) {
|
|
331
|
-
var id = oBindingContext.getObject().id;
|
|
332
|
-
return this._cellFragments[id];
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Handler for the demo app cell creation
|
|
337
|
-
*
|
|
338
|
-
* @param {sap.ui.model.Context} oBindingContext the context for the current cell
|
|
339
|
-
* @param {sap.ui.core.Control[]} aFragments the fragments for the current cell [teaser, default cell]
|
|
340
|
-
* @return {sap.ui.layout.BlockLayoutCell} the demo app cell
|
|
341
|
-
* @private
|
|
342
|
-
**/
|
|
343
|
-
onDemoAppCellCreated: function (oBindingContext, aFragments) {
|
|
344
|
-
var oTeaser = aFragments[0],
|
|
345
|
-
oBlockLayoutCell = aFragments[1];
|
|
346
|
-
|
|
347
|
-
oBlockLayoutCell.getContent()[0].addContent(oTeaser);
|
|
348
|
-
sap.ui.loader.config({paths:{"test-resources":null}});
|
|
349
|
-
//sets the teaser to aria-hidden => gets ignored by screen reader
|
|
350
|
-
oTeaser.addEventDelegate({"onAfterRendering": function() {
|
|
351
|
-
this.getParent().getDomRef().childNodes[1].setAttribute("aria-hidden", "true");
|
|
352
|
-
}.bind(oTeaser)});
|
|
353
|
-
|
|
354
|
-
oBlockLayoutCell.setBindingContext(oBindingContext);
|
|
355
|
-
return oBlockLayoutCell;
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Handler for the demo app cell creation error
|
|
360
|
-
* Creates and returns a normal demo app cell instead as promise
|
|
361
|
-
*
|
|
362
|
-
* @param {sap.ui.model.Context} oBindingContext the context for the current cell
|
|
363
|
-
* @param {Error} oException the exception that occurred during the cell creation
|
|
364
|
-
* @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
|
|
365
|
-
* @private
|
|
366
|
-
**/
|
|
367
|
-
onDemoAppCellFailed: function (oBindingContext, oException) {
|
|
368
|
-
Log.warning("Teaser for demo app \"" + oBindingContext.name + "\" could not be loaded: " + oException);
|
|
369
|
-
return this.createNormalDemoAppCell(oBindingContext);
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Creates a normal demo app cell
|
|
374
|
-
* @param {sap.ui.model.Context} oBindingContext the context for the current cell
|
|
375
|
-
* @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
|
|
376
|
-
* @private
|
|
377
|
-
**/
|
|
378
|
-
createNormalDemoAppCell: function (oBindingContext) {
|
|
379
|
-
return new Promise(function (resolve) {
|
|
380
|
-
Fragment.load({
|
|
381
|
-
id: oBindingContext.id,
|
|
382
|
-
name: "sap.ui.documentation.sdk.view.BlockLayoutCell",
|
|
383
|
-
controller: this
|
|
384
|
-
}).then(function (oBlockLayoutCell) {
|
|
385
|
-
oBlockLayoutCell.setBindingContext(oBindingContext);
|
|
386
|
-
resolve(oBlockLayoutCell);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return oPromise;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Adds the license file to the zip file.
|
|
169
|
+
*
|
|
170
|
+
* @param {Array} aPromises - The array of promises.
|
|
171
|
+
* @param {object} oZipFile - The zip file.
|
|
172
|
+
*/
|
|
173
|
+
addLicenseFileToZip: function (aPromises, oZipFile) {
|
|
174
|
+
var sUrl = sap.ui.require.toUrl("LICENSE.txt").replace("resources/", ""),
|
|
175
|
+
oLicensePromise = ResourceDownloadUtil.fetch(sUrl),
|
|
176
|
+
oLicensePromiseWrapper = new Promise(function (resolve, reject) {
|
|
177
|
+
oLicensePromise.then(function (oContent) {
|
|
178
|
+
oZipFile.file("LICENSE.txt", oContent);
|
|
179
|
+
resolve();
|
|
180
|
+
}).catch(function () {
|
|
181
|
+
resolve();
|
|
387
182
|
});
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Creates a demo app cell with a teaser
|
|
393
|
-
*
|
|
394
|
-
* @param {sap.ui.model.Context} oBindingContext the context for the current cell
|
|
395
|
-
* @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
|
|
396
|
-
* @private
|
|
397
|
-
**/
|
|
398
|
-
createDemoAppCellFromTeaser: function (oBindingContext) {
|
|
399
|
-
sap.ui.loader.config({paths:{"test-resources":"test-resources"}});
|
|
400
|
-
var sRelativePath = sap.ui.require.toUrl(oBindingContext.teaser),
|
|
401
|
-
oPromiseTeaser = Fragment.load({
|
|
402
|
-
id: oBindingContext.id,
|
|
403
|
-
name: sRelativePath,
|
|
404
|
-
controller: this
|
|
405
|
-
}),
|
|
406
|
-
oPromiseCell = Fragment.load({
|
|
407
|
-
id: oBindingContext.id,
|
|
408
|
-
name: "sap.ui.documentation.sdk.view.BlockLayoutTeaserCell",
|
|
409
|
-
controller: this
|
|
410
|
-
}),
|
|
411
|
-
onCreated = this.onDemoAppCellCreated.bind(this, oBindingContext),
|
|
412
|
-
onFailed = this.onDemoAppCellFailed.bind(this, oBindingContext);
|
|
413
|
-
|
|
414
|
-
return Promise.all([oPromiseTeaser, oPromiseCell])
|
|
415
|
-
.then(function (aFragments) {
|
|
416
|
-
return onCreated(aFragments);
|
|
417
|
-
})
|
|
418
|
-
.catch(function (oException) {
|
|
419
|
-
return onFailed(oException);
|
|
420
|
-
});
|
|
421
|
-
},
|
|
183
|
+
});
|
|
422
184
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
185
|
+
aPromises.push(oLicensePromiseWrapper);
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Handles the completion of the promises.
|
|
190
|
+
*
|
|
191
|
+
* @param {Array} aPromises - The array of promises.
|
|
192
|
+
* @param {Array} aFails - The array of failed promises.
|
|
193
|
+
* @param {object} oZipFile - The zip file.
|
|
194
|
+
* @param {object} oListItem - The list item.
|
|
195
|
+
*/
|
|
196
|
+
handlePromisesCompletion: function (aPromises, aFails, oZipFile, oListItem) {
|
|
197
|
+
Promise.all(aPromises).then(function () {
|
|
198
|
+
if (aFails.length) {
|
|
199
|
+
var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
|
|
200
|
+
return sErrorMessage + sError + "\n";
|
|
201
|
+
}, "Could not locate the following download files:\n");
|
|
202
|
+
this.handleError(sCompleteErrorMessage);
|
|
436
203
|
}
|
|
437
|
-
},
|
|
438
|
-
|
|
439
|
-
/* =========================================================== */
|
|
440
|
-
/* helper methods */
|
|
441
|
-
/* =========================================================== */
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Archive creation function that can be stubbed easily in tests
|
|
445
|
-
* @param {object} File the jszip file handle
|
|
446
|
-
* @param {object} oContent the blob for the zip file
|
|
447
|
-
* @param {string} sFilename the file name
|
|
448
|
-
* @private
|
|
449
|
-
*/
|
|
450
|
-
_createArchive: function (File, oContent, sFilename) {
|
|
451
|
-
File.save(oContent, sFilename, "zip", "application/zip");
|
|
452
|
-
},
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Error handler function that can be stubbed easily in tests
|
|
456
|
-
* @param {string} sError the error message
|
|
457
|
-
* @private
|
|
458
|
-
*/
|
|
459
|
-
_handleError: function (sError) {
|
|
460
|
-
MessageBox.error(sError);
|
|
461
|
-
},
|
|
462
204
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
205
|
+
MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
|
|
206
|
+
|
|
207
|
+
var oContent = oZipFile.generate({ type: "blob" });
|
|
208
|
+
this.createArchive(oContent, oListItem.getLabel());
|
|
209
|
+
}.bind(this));
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Error handler function that can be stubbed easily in tests
|
|
214
|
+
* @param {string} sError the error message
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
handleError: function (sError) {
|
|
218
|
+
MessageBox.error(sError);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|