Add cordova device plugin and zoom in home page

The user can now zoom in/out the network graph in the home page with
two buttons.

Added the cordova device plugin to detect when the phone is ready and
the change the behavior of the backbutton on android.

Disabled the panel left swipe because of some scroll problems in
landscape mode.
This commit is contained in:
dario-cfpt
2020-03-07 15:26:38 +01:00
parent 2fb4a2f13e
commit f2c26ce8c1
7 changed files with 560 additions and 10 deletions

View File

@ -95,3 +95,33 @@ function displayCharacters() {
}]
});
}
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
const container = document.getElementById("container-characters");
container.style.zoom = 1;
$$("#zoom-in").on("click", () => {
let zoom = Number(container.style.zoom) + 0.25;
container.style.zoom = zoom;
app.range.setValue("#range-zoom", zoom);
});
$$("#zoom-out").on("click", () => {
let zoom = Number(container.style.zoom) - 0.25;
container.style.zoom = zoom;
app.range.setValue("#range-zoom", zoom);
});
}
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
if ($$('.panel').hasClass("panel-active")) {
app.panel.close(".panel");
} else if ($$('.modal-in').length > 0) {
app.smartSelect.close("#select-compare"); // TODO: fix that
} else if ($$('.back').length > 0) {
mainView.router.back();
} else {
navigator.app.exitApp();
}
}