-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComponent.js
executable file
·76 lines (66 loc) · 2.61 KB
/
Component.js
1
2
3
4
5
6
7
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
/* global document */
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"sap/ui/demo/masterdetail/model/models",
"sap/ui/demo/masterdetail/controller/ListSelector",
"sap/ui/demo/masterdetail/controller/ErrorHandler"
], function (UIComponent, Device, models, ListSelector, ErrorHandler) {
"use strict";
return UIComponent.extend("sap.ui.demo.masterdetail.Component", {
metadata : {
manifest : "json"
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* In this method, the FLP and device models are set and the router is initialized.
* @public
* @override
*/
init : function () {
this.oListSelector = new ListSelector();
this._oErrorHandler = new ErrorHandler(this);
// set the device model
this.setModel(models.createDeviceModel(), "device");
// set the FLP model
this.setModel(models.createFLPModel(), "FLP");
// call the base component's init function and create the App view
UIComponent.prototype.init.apply(this, arguments);
// create the views based on the url/hash
this.getRouter().initialize();
},
/**
* The component is destroyed by UI5 automatically.
* In this method, the ListSelector and ErrorHandler are destroyed.
* @public
* @override
*/
destroy : function () {
this.oListSelector.destroy();
this._oErrorHandler.destroy();
// call the base component's destroy function
UIComponent.prototype.destroy.apply(this, arguments);
},
/**
* This method can be called to determine whether the sapUiSizeCompact or sapUiSizeCozy
* design mode class should be set, which influences the size appearance of some controls.
* @public
* @return {string} css class, either 'sapUiSizeCompact' or 'sapUiSizeCozy' - or an empty string if no css class should be set
*/
getContentDensityClass : function() {
if (this._sContentDensityClass === undefined) {
// check whether FLP has already set the content density class; do nothing in this case
if (jQuery(document.body).hasClass("sapUiSizeCozy") || jQuery(document.body).hasClass("sapUiSizeCompact")) {
this._sContentDensityClass = "";
} else if (!Device.support.touch) { // apply "compact" mode if touch is not supported
this._sContentDensityClass = "sapUiSizeCompact";
} else {
// "cozy" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table
this._sContentDensityClass = "sapUiSizeCozy";
}
}
return this._sContentDensityClass;
}
});
}
);