@@ -61,17 +61,9 @@ define([
61
61
* Handle button click, init the Page Builder application
62
62
*/
63
63
pageBuilderEditButtonClick : function ( context , event ) {
64
- var modalInnerWrap = $ ( event . currentTarget ) . parents ( '.modal-inner-wrap' ) ;
65
-
64
+ this . determineIfWithinModal ( event . currentTarget ) ;
66
65
this . transition ( false ) ;
67
66
68
- // Determine if the Page Builder instance is within a modal
69
- this . isWithinModal = modalInnerWrap . length === 1 ;
70
-
71
- if ( this . isWithinModal ) {
72
- this . modal = modalInnerWrap ;
73
- }
74
-
75
67
if ( ! this . isComponentInitialized ( ) ) {
76
68
this . disableDomObserver ( $ ( event . currentTarget ) . parent ( ) [ 0 ] ) ;
77
69
}
@@ -108,9 +100,26 @@ define([
108
100
* @param {HTMLElement } node
109
101
*/
110
102
disableDomObserver : function ( node ) {
103
+ this . determineIfWithinModal ( node ) ;
111
104
domObserver . disableNode ( node ) ;
112
105
} ,
113
106
107
+ /**
108
+ * Determine if the current instance is within a modal
109
+ *
110
+ * @param {HTMLElement } element
111
+ */
112
+ determineIfWithinModal : function ( element ) {
113
+ var modalInnerWrap = $ ( element ) . parents ( '.modal-inner-wrap' ) ;
114
+
115
+ // Determine if the Page Builder instance is within a modal
116
+ this . isWithinModal = modalInnerWrap . length === 1 ;
117
+
118
+ if ( this . isWithinModal ) {
119
+ this . modal = modalInnerWrap ;
120
+ }
121
+ } ,
122
+
114
123
/**
115
124
* Toggle Page Builder full screen mode
116
125
*/
@@ -141,14 +150,14 @@ define([
141
150
} . bind ( this ) ) ;
142
151
143
152
events . on ( 'stage:' + id + ':fullScreenModeChangeAfter' , function ( args ) {
144
- if ( ! args . fullScreen && this . wysiwygConfigData ( ) [ 'pagebuilder_button' ] ) {
145
- if ( this . isWithinModal && this . modal ) {
146
- this . modal . css ( {
147
- transform : '' ,
148
- transition : ''
149
- } ) ;
150
- }
153
+ if ( this . isWithinModal && this . modal ) {
154
+ this . modal . css ( {
155
+ transform : '' ,
156
+ transition : ''
157
+ } ) ;
158
+ }
151
159
160
+ if ( ! args . fullScreen && this . wysiwygConfigData ( ) [ 'pagebuilder_button' ] ) {
152
161
// Force full screen mode whilst the animation occurs
153
162
this . transitionOut ( true ) ;
154
163
// Trigger animation out
@@ -159,23 +168,25 @@ define([
159
168
this . transitionOut ( false ) ;
160
169
this . visiblePageBuilder ( false ) ;
161
170
} . bind ( this ) , 185 ) ;
162
- } else if ( args . fullScreen && this . wysiwygConfigData ( ) [ 'pagebuilder_button' ] ) {
163
- this . visiblePageBuilder ( true ) ;
164
-
171
+ } else if ( args . fullScreen ) {
165
172
if ( this . isWithinModal && this . modal ) {
166
173
this . modal . css ( {
167
174
transform : 'none' ,
168
175
transition : 'none'
169
176
} ) ;
170
177
}
171
178
172
- fullScreenDeferred . resolve ( ) ;
179
+ if ( this . wysiwygConfigData ( ) [ 'pagebuilder_button' ] ) {
180
+ this . visiblePageBuilder ( true ) ;
181
+
182
+ fullScreenDeferred . resolve ( ) ;
173
183
174
- // If the stage has already rendered once we don't need to wait until animating the stage in
175
- if ( rendered ) {
176
- _ . defer ( function ( ) {
177
- this . transition ( true ) ;
178
- } . bind ( this ) ) ;
184
+ // If the stage has already rendered once we don't need to wait until animating the stage in
185
+ if ( rendered ) {
186
+ _ . defer ( function ( ) {
187
+ this . transition ( true ) ;
188
+ } . bind ( this ) ) ;
189
+ }
179
190
}
180
191
}
181
192
} . bind ( this ) ) ;
0 commit comments