Skip to content

Commit

Permalink
feat: size window for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
rivexe committed Feb 28, 2024
1 parent 40600ad commit f749e9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#body-public #content {
height: 100%;
}
#content-wrapper #content {
height: calc(100dvh - 45px);
}

.AscDesktopEditor #header {
display: none;
Expand Down
31 changes: 31 additions & 0 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
OCA.Onlyoffice.showMessage(config.error, {type: "error"});
return;
}
OCA.Onlyoffice.device = config.type;
if (OCA.Onlyoffice.device === "mobile") {
OCA.Onlyoffice.resizeEvents();
}

var docIsChanged = null;
var docIsChangedTimeout = null;
Expand Down Expand Up @@ -267,6 +271,8 @@
if (OCA.Onlyoffice.version > 0) {
OCA.Onlyoffice.onRequestHistory(OCA.Onlyoffice.version);
}

OCA.Onlyoffice.resize();
};

OCA.Onlyoffice.onRequestSaveAs = function (event) {
Expand Down Expand Up @@ -661,6 +667,31 @@
OCA.Onlyoffice.docEditor.refreshHistory(data);
}

OCA.Onlyoffice.resize = function () {
if (OCA.Onlyoffice.device !== "mobile") {
return;
}

var headerHeight = $("#header").length > 0 ? $("#header").height() : 45;
var wrapEl = $("#app>iframe");
if (wrapEl.length > 0) {
wrapEl[0].style.height = (screen.availHeight - headerHeight) + "px";
window.scrollTo(0, -1);
wrapEl[0].style.height = (window.innerHeight - headerHeight) + "px";
}
};

OCA.Onlyoffice.resizeEvents = function() {
if (window.addEventListener) {
if (/Android/i.test(navigator.userAgent)) {
window.addEventListener("resize", OCA.Onlyoffice.resize);
}
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
window.addEventListener("orientationchange", OCA.Onlyoffice.resize);
}
}
};

$(document).ready(OCA.Onlyoffice.InitEditor);

})(jQuery, OCA);

0 comments on commit f749e9a

Please sign in to comment.