Skip to content

Commit

Permalink
Merge pull request #949 from ONLYOFFICE/feature/window-size
Browse files Browse the repository at this point in the history
Feature/window size
  • Loading branch information
LinneyS authored Feb 26, 2024
2 parents eb096db + 9296d3c commit 6b6f1f6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- offline viewer for share link
- updatable list of supported formats
- filling pdf instead oform
- fixed mobile editor size

## Added
- advanced access rights for talk files and share links
Expand Down
4 changes: 2 additions & 2 deletions css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
position: fixed;
vertical-align: top;
left: 0px;
height: calc(100vh - 58px);
height: calc(100dvh - 58px);
margin-top: -50px;
}

#content.app-onlyoffice #app > iframe {
height: calc(100vh - 50px);
height: calc(100dvh - 50px);
margin-top: 0px;
}

Expand Down
32 changes: 32 additions & 0 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
url: configUrl,
success: function onSuccess(config) {
if (config) {
OCA.Onlyoffice.device = config.type;
if (OCA.Onlyoffice.device === "mobile") {
OCA.Onlyoffice.resizeEvents();
}

if (config.redirectUrl) {
location.href = config.redirectUrl;
return;
Expand Down Expand Up @@ -293,6 +298,8 @@
if (OCA.Onlyoffice.version > 0) {
OCA.Onlyoffice.onRequestHistory(OCA.Onlyoffice.version);
}

OCA.Onlyoffice.resize();
};

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

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

var headerHeight = $("#header").length > 0 ? $("#header").height() : 50;
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);
}
}
};

OCA.Onlyoffice.InitEditor();

})(jQuery, OCA);

0 comments on commit 6b6f1f6

Please sign in to comment.