Skip to content

Commit

Permalink
Merge pull request #2991 from ONLYOFFICE/feature/repaire-mobile-fulls…
Browse files Browse the repository at this point in the history
…creen

Feature/repaire mobile fullscreen
  • Loading branch information
maxkadushkin authored May 17, 2024
2 parents 1955a20 + a97618b commit 6400cb9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
26 changes: 26 additions & 0 deletions apps/common/main/lib/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,32 @@ Common.Utils.injectComponent = function ($slot, cmp) {
}
};

Common.Utils.startFullscreenForElement = function (element) {
if (element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
}

Common.Utils.cancelFullscreen = function () {
if(document.cancelFullScreen) {
document.cancelFullScreen();
} else if(document.webkitCancelFullScreen ) {
document.webkitCancelFullScreen();
} else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if(document.msExitFullscreen) {
document.msExitFullscreen();
}
}

Common.Utils.warningDocumentIsLocked = function (opts) {
if ( opts.disablefunc )
opts.disablefunc(true);
Expand Down
16 changes: 1 addition & 15 deletions apps/presentationeditor/main/app/controller/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ define([
};
if (!me.viewport.mode.isDesktopApp && !Common.Utils.isIE11 && !presenter && !!document.fullscreenEnabled) {
Common.NotificationCenter.on('window:resize', _onWindowResize);
!fromApiEvent && me.fullScreen(document.documentElement);
!fromApiEvent && Common.Utils.startFullscreenForElement($("#pe-preview").get(0));
setTimeout(function(){
_onWindowResize();
}, 100);
Expand All @@ -287,20 +287,6 @@ define([
}
},

fullScreen: function(element) {
if (element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
},

onFileMenu: function (opts) {
var me = this;
var _need_disable = opts == 'show';
Expand Down
15 changes: 11 additions & 4 deletions apps/presentationeditor/main/app/view/DocumentPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ define([

onEndDemonstration: function( ) {
this.hide();
this.fullScreenCancel();
Common.Utils.cancelFullscreen();
},

onDemonstrationStatus: function(status) {
Expand All @@ -386,10 +386,17 @@ define([

toggleFullScreen: function() {
if (!document.fullscreenElement && !document.msFullscreenElement &&
!document.mozFullScreenElement && !document.webkitFullscreenElement) {
this.fullScreen(document.documentElement);
!document.mozFullScreenElement && !document.webkitFullscreenElement)
{
if (this.mode.isDesktopApp || Common.Utils.isIE11) return;
const elem = document.getElementById('pe-preview');
if ( elem ) {
Common.Utils.startFullscreenForElement(elem);
this.previewControls.css('display', 'none');
this.$el.css('cursor', 'none');
}
} else {
this.fullScreenCancel();
Common.Utils.cancelFullscreen();
}
},

Expand Down

0 comments on commit 6400cb9

Please sign in to comment.