-
-
Notifications
You must be signed in to change notification settings - Fork 864
/
cordova_startup.js
65 lines (62 loc) · 1.95 KB
/
cordova_startup.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
'use strict';
const cordovaUI = {
uiZoom: 1,
canChangeUI: true,
init: async function() {
const self = this;
const screenWidth = $(window).width();
const screenHeight = $(window).height();
let length;
let orientation;
if (screenWidth > screenHeight) {
length = screenWidth;
orientation = 'landscape';
} else {
length = screenHeight;
orientation = 'portrait';
}
if (length < 1024) {
self.uiZoom = length/1024;
}
if (screenWidth > 575 && screenHeight > 575) {
self.canChangeUI = false;
}
const result = ConfigStorage.get('cordovaForceComputerUI');
if (result.cordovaForceComputerUI === undefined) {
if ((orientation === 'landscape' && screenHeight <= 575)
|| (orientation === 'portrait' && screenWidth <= 575)) {
ConfigStorage.set({'cordovaForceComputerUI': false});
} else {
ConfigStorage.set({'cordovaForceComputerUI': true});
}
}
self.set();
},
set: function() {
const self = this;
const result = ConfigStorage.get('cordovaForceComputerUI');
if (result.cordovaForceComputerUI) {
window.screen.orientation.lock('landscape');
$('body').css('zoom', self.uiZoom);
} else {
window.screen.orientation.lock('portrait');
$('body').css('zoom', 1);
}
},
};
const cordovaApp = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
$('.open_firmware_flasher, .tab_firmware_flasher').hide();
cordovaUI.init();
navigator.splashscreen.hide();
cordovaChromeapi.init();
appReady();
},
};
cordovaApp.initialize();