@@ -60,15 +60,7 @@ widgets.FullScreen = Class.create({
6060 this . toolbarPlaceholder = new Element ( "span" ) ;
6161 // The controls that will close the fullscreen
6262 this . createCloseButtons ( ) ;
63- // When coming back from preview, check if the user was in full screen before hitting preview, and if so restore
64- // that full screen
6563 this . maximizedReference = $ ( document . body ) . down ( "input[name='x-maximized']" ) ;
66- if ( this . maximizedReference && this . maximizedReference . value != "" ) {
67- var matches = $$ ( this . maximizedReference . value ) ;
68- if ( matches && matches . length > 0 ) {
69- this . makeFullScreen ( matches [ 0 ] ) ;
70- }
71- }
7264 // Cleanup before the window unloads.
7365 this . unloadHandler = this . cleanup . bind ( this ) ;
7466 Event . observe ( window , 'unload' , this . unloadHandler ) ;
@@ -88,6 +80,16 @@ widgets.FullScreen = Class.create({
8880 }
8981 }
9082 } ,
83+ restoreFullscreenFromPreview : function ( ) {
84+ // When coming back from preview, check if the user was in full screen before hitting preview, and if so restore
85+ // that full screen
86+ if ( this . maximizedReference && this . maximizedReference . value != "" ) {
87+ var matches = $$ ( this . maximizedReference . value ) ;
88+ if ( matches && matches . length > 0 ) {
89+ this . makeFullScreen ( matches [ 0 ] ) ;
90+ }
91+ }
92+ } ,
9193 isAlreadyAugmented : function ( item ) {
9294 return typeof item . _x_fullScreenActivator !== 'undefined' ;
9395 } ,
@@ -412,12 +414,14 @@ require(['jquery', 'xwiki-events-bridge'], function ($) {
412414 XWiki . widgets . __fullscreenInstance . initDom ( ) ;
413415 XWiki . widgets . __fullscreenInstance . addBehavior ( $ ( this ) [ 0 ] ) ;
414416 } ) ;
417+ XWiki . widgets . __fullscreenInstance . restoreFullscreenFromPreview ( ) ;
415418 } ) ;
416419 let init = function ( ) {
417420 XWiki . widgets . __fullscreenInstance . initDom ( ) ;
418421 $ ( document ) . find ( 'textarea,.maximizable' ) . each ( function ( ) {
419422 XWiki . widgets . __fullscreenInstance . addBehavior ( $ ( this ) [ 0 ] ) ;
420423 } ) ;
424+ XWiki . widgets . __fullscreenInstance . restoreFullscreenFromPreview ( ) ;
421425 }
422426 XWiki . domIsLoaded && init ( ) || document . observe ( 'xwiki:dom:loaded' , init ) ;
423427} ) ;
0 commit comments