From 2b8ca78940752c6641125e552bcc8c3b30b2dffd Mon Sep 17 00:00:00 2001 From: Hao Sun Date: Thu, 29 Jul 2021 15:49:07 +0800 Subject: [PATCH] * handle situations where the full screen interface is not available. --- module/doc/js/objectlibs.js | 40 ++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/module/doc/js/objectlibs.js b/module/doc/js/objectlibs.js index 3a7a6e46c6..9110d1d1cd 100644 --- a/module/doc/js/objectlibs.js +++ b/module/doc/js/objectlibs.js @@ -48,13 +48,35 @@ function fullScreen() var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; if(requestMethod) { - $('#mainActions').removeClass('hidden'); - $('#content').addClass('scrollbar-hover'); - $('#content .actions').addClass('hidden'); - $('#content .file-image .right-icon').addClass('hidden'); - $('#content .files-list .right-icon').addClass('hidden'); - requestMethod.call(element); - $.cookie('isFullScreen', 1); + var afterEnterFullscreen = function() + { + $('#mainActions').removeClass('hidden'); + $('#content').addClass('scrollbar-hover'); + $('#content .actions').addClass('hidden'); + $('#content .file-image .right-icon').addClass('hidden'); + $('#content .files-list .right-icon').addClass('hidden'); + $.cookie('isFullScreen', 1); + }; + var whenFailEnterFullscreen = function(error) + { + $.cookie('isFullScreen', 0); + }; + try + { + var result = requestMethod.call(element); + if(result && (typeof result.then === 'function' || result instanceof window.Promise)) + { + result.then(afterEnterFullscreen).catch(whenFailEnterFullscreen); + } + else + { + afterEnterFullscreen(); + } + } + catch (error) + { + whenFailEnterFullscreen(error); + } } } @@ -127,6 +149,10 @@ $(function() $('#content').html($tmpDiv.find('#content').html()); $('#sidebarContent').html($tmpDiv.find('#sidebarContent').html()); $('#actionbox .histories-list').html($tmpDiv.find('#actionbox .histories-list').html()); + if($.cookie('isFullScreen') == 1) fullScreen(); + $('#content [data-ride="tree"]').tree(); + $('#outline li.has-list').addClass('open in'); + $('#outline li.has-list>i+ul').prev('i').remove(); }); }); })