2121 * primaryActionButtonType: A string to be used as type for primary action button.
2222 * primaryActionButtonTitle: A string to be used as title for primary action button.
2323 * showEditorModeButtons: Whether to show editor mode button in the modal header.
24+ * showFullscreenButton: Whether to show fullscreen button in the modal header.
2425 */
2526define ( [ 'jquery' , 'underscore' , 'gettext' , 'js/views/baseview' ] ,
2627 function ( $ , _ , gettext , BaseView ) {
@@ -43,7 +44,8 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview'],
4344 addPrimaryActionButton : false ,
4445 primaryActionButtonType : 'save' ,
4546 primaryActionButtonTitle : gettext ( 'Save' ) ,
46- showEditorModeButtons : true
47+ showEditorModeButtons : true ,
48+ showFullscreenButton : false ,
4749 } ) ,
4850
4951 initialize : function ( ) {
@@ -71,7 +73,8 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview'],
7173 title : this . getTitle ( ) ,
7274 modalSRTitle : this . options . modalSRTitle ,
7375 showEditorModeButtons : this . options . showEditorModeButtons ,
74- viewSpecificClasses : this . options . viewSpecificClasses
76+ viewSpecificClasses : this . options . viewSpecificClasses ,
77+ showFullscreenButton : this . options . showFullscreenButton ,
7578 } ) ) ;
7679 this . addActionButtons ( ) ;
7780 this . renderContents ( ) ;
@@ -83,9 +86,14 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview'],
8386 } ,
8487
8588 renderContents : function ( ) {
86- var contentHtml = this . getContentHtml ( ) ;
89+ const contentHtml = this . getContentHtml ( ) ;
8790 // xss-lint: disable=javascript-jquery-html
8891 this . $ ( '.modal-content' ) . html ( contentHtml ) ;
92+
93+ const fullscreenButton = this . $ ( '.fullscreen-button' ) ;
94+ if ( fullscreenButton . length ) {
95+ fullscreenButton . bind ( 'click' , this . toggleFullscreen . bind ( this ) ) ;
96+ }
8997 } ,
9098
9199 /**
@@ -106,6 +114,7 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview'],
106114 // after showing and resizing, send focus
107115 this . $el . find ( this . options . modalWindowClass ) . focus ( ) ;
108116 }
117+
109118 } ,
110119
111120 hide : function ( ) {
@@ -195,11 +204,25 @@ define(['jquery', 'underscore', 'gettext', 'js/views/baseview'],
195204 this . getActionBar ( ) . find ( '.action-' + type ) . prop ( 'disabled' , true ) . addClass ( 'is-disabled' ) ;
196205 } ,
197206
207+ toggleFullscreen : function ( ) {
208+ this . $ ( '.fullscreen-button .icon' ) . toggleClass ( 'fa-expand fa-compress' ) ;
209+ this . $ ( '.modal-editor' ) . toggleClass ( `modal-${ this . options . modalSize } modal-fullscreen` ) ;
210+ this . resize ( ) ;
211+ } ,
212+
198213 resize : function ( ) {
199214 var top , left , modalWindow , modalWidth , modalHeight ,
200215 availableWidth , availableHeight , maxWidth , maxHeight ;
201216
202217 modalWindow = this . $el . find ( this . options . modalWindowClass ) ;
218+ if ( modalWindow . hasClass ( 'modal-fullscreen' ) ) {
219+ // Remove previously set width and height from the modal window
220+ modalWindow . css ( {
221+ top : '' ,
222+ left : '' ,
223+ } ) ;
224+ return ;
225+ }
203226 availableWidth = $ ( window ) . width ( ) ;
204227 availableHeight = $ ( window ) . height ( ) ;
205228 maxWidth = availableWidth * 0.98 ;
0 commit comments