@@ -22,7 +22,7 @@ export default Base.extend({
22
22
// links, forms and subforms inject modals
23
23
trigger :
24
24
"div.pat-modal, a.pat-modal, form.pat-modal, .pat-modal.pat-subform" ,
25
- init : function ( $el , opts , trigger ) {
25
+ init ( $el , opts , trigger ) {
26
26
this . options = parser . parse ( this . $el , opts ) ;
27
27
if ( trigger && trigger . type === "injection" ) {
28
28
$ . extend (
@@ -37,8 +37,8 @@ export default Base.extend({
37
37
}
38
38
} ,
39
39
40
- _init_inject1 : function ( ) {
41
- var opts = {
40
+ _init_inject1 ( ) {
41
+ const opts = {
42
42
target : "#pat-modal" ,
43
43
class :
44
44
"pat-modal" +
@@ -55,17 +55,14 @@ export default Base.extend({
55
55
if ( ! this . $el . closest ( "#pat-modal" ) ) {
56
56
$ ( "#pat-modal" ) . detach ( ) ;
57
57
}
58
- this . $el . on (
59
- "pat-inject-missingSource pat-inject-missingTarget" ,
60
- function ( ) {
61
- $ ( "#pat-modal" ) . detach ( ) ;
62
- }
63
- ) ;
58
+ this . $el . on ( "pat-inject-missingSource pat-inject-missingTarget" , ( ) => {
59
+ $ ( "#pat-modal" ) . detach ( ) ;
60
+ } ) ;
64
61
inject . init ( this . $el , opts ) ;
65
62
} ,
66
63
67
- _init_div1 : function ( ) {
68
- var $header = $ ( "<div class='header' />" ) ;
64
+ _init_div1 ( ) {
65
+ const $header = $ ( "<div class='header' />" ) ;
69
66
if ( this . options . closing . indexOf ( "close-button" ) !== - 1 ) {
70
67
$ (
71
68
"<button type='button' class='close-panel'>" +
@@ -104,7 +101,7 @@ export default Base.extend({
104
101
$ ( "body" ) . addClass ( "modal-active" ) ;
105
102
} ,
106
103
107
- _init_handlers : function ( ) {
104
+ _init_handlers ( ) {
108
105
$ ( document ) . on (
109
106
"click.pat-modal" ,
110
107
"#pat-modal .close-panel[type!=submit]" ,
@@ -153,45 +150,44 @@ export default Base.extend({
153
150
) ;
154
151
} ,
155
152
156
- _onPossibleOutsideClick : function ( ev ) {
153
+ _onPossibleOutsideClick ( ev ) {
157
154
if ( this . $el . has ( ev . target ) ) {
158
155
this . destroy ( ) ;
159
156
}
160
157
} ,
161
158
162
- _onKeyUp : function ( ev ) {
159
+ _onKeyUp ( ev ) {
163
160
if ( ev . which === 27 ) {
164
161
this . destroy ( ) ;
165
162
}
166
163
} ,
167
164
168
- getTallestChild : function ( ) {
169
- var $tallest_child ;
170
- $ ( "*" , this . $el ) . each ( function ( ) {
171
- var $child = $ ( this ) ;
165
+ getTallestChild ( ) {
166
+ let $tallest_child ;
167
+ for ( const child of $ ( "*" , this . $el ) ) {
168
+ const $child = $ ( child ) ;
172
169
if ( typeof $tallest_child === "undefined" ) {
173
170
$tallest_child = $child ;
174
171
} else if (
175
172
$child . outerHeight ( true ) > $tallest_child . outerHeight ( true )
176
173
) {
177
174
$tallest_child = $child ;
178
175
}
179
- } ) ;
176
+ }
180
177
return $tallest_child ;
181
178
} ,
182
179
183
- setPosition : function ( ) {
180
+ setPosition ( ) {
184
181
this . $el . css ( "top" , ( $ ( window ) . innerHeight ( ) - this . $el . height ( ) ) / 2 ) ;
185
182
} ,
186
183
187
- resize : function ( ) {
184
+ resize ( ) {
188
185
// reset the height before setting a new one
189
186
this . $el . removeClass ( "max-height" ) . css ( "height" , "" ) ;
190
187
191
- var panel_content_elem = this . $el . find ( ".panel-content" ) ;
192
- var header_elem = this . $el . find ( ".header" ) ;
193
-
194
- var modal_height =
188
+ const panel_content_elem = this . $el . find ( ".panel-content" ) ;
189
+ const header_elem = this . $el . find ( ".header" ) ;
190
+ const modal_height =
195
191
panel_content_elem . outerHeight ( true ) +
196
192
header_elem . outerHeight ( true ) ;
197
193
if ( this . $el . height ( ) < modal_height ) {
@@ -210,22 +206,20 @@ export default Base.extend({
210
206
utils . redraw ( this . $el . find ( ".panel-body" ) ) ;
211
207
}
212
208
} ,
213
- destroy : function ( ) {
214
- var $el = this . $el ;
209
+ destroy ( ) {
215
210
// if working without injection, destroy right away.
216
211
$ ( document ) . off ( ".pat-modal" ) ;
217
- $el . remove ( ) ;
212
+ this . $el . remove ( ) ;
218
213
$ ( "body" ) . removeClass ( "modal-active" ) ;
219
214
$ ( "body" ) . removeClass ( "modal-panel" ) ;
220
215
} ,
221
- destroy_inject : function ( ) {
222
- var $el = this . $el ;
223
- if ( $el . find ( "form" ) . hasClass ( "pat-inject" ) ) {
216
+ destroy_inject ( ) {
217
+ if ( this . $el . find ( "form" ) . hasClass ( "pat-inject" ) ) {
224
218
// if pat-inject in modal form, listen to patterns-inject-triggered and destroy first
225
219
// once that has been triggered
226
220
let destroy_handler = ( ) => {
227
221
$ ( document ) . off ( ".pat-modal" ) ;
228
- $el . remove ( ) ;
222
+ this . $el . remove ( ) ;
229
223
$ ( "body" ) . removeClass ( "modal-active" ) ;
230
224
$ ( "body" ) . removeClass ( "modal-panel" ) ;
231
225
$ ( "body" ) . off ( "patterns-inject-triggered" , destroy_handler ) ;
@@ -234,7 +228,7 @@ export default Base.extend({
234
228
} else {
235
229
// if working without injection, destroy right away.
236
230
$ ( document ) . off ( ".pat-modal" ) ;
237
- $el . remove ( ) ;
231
+ this . $el . remove ( ) ;
238
232
$ ( "body" ) . removeClass ( "modal-active" ) ;
239
233
$ ( "body" ) . removeClass ( "modal-panel" ) ;
240
234
}
0 commit comments