@@ -85,7 +85,6 @@ export default Base.extend({
85
85
interactive : true ,
86
86
onHide : this . _onHide . bind ( this ) ,
87
87
onShow : this . _onShow . bind ( this ) ,
88
- onMount : this . _onMount . bind ( this ) ,
89
88
trigger : "click" ,
90
89
} ;
91
90
@@ -262,34 +261,16 @@ export default Base.extend({
262
261
} ,
263
262
264
263
async _onShow ( ) {
265
- if ( this . options . closing !== "auto" && this . options . trigger === "hover" ) {
266
- // no auto-close when hovering when closing mode is "sticky" or "close-button".
267
- this . tippy . setProps ( { trigger : "click" } ) ;
268
- }
264
+ const tippy_classes = [ ] ;
269
265
270
- if ( this . options . markInactive ) {
271
- this . el . classList . remove ( this . inactive_class ) ;
272
- this . el . classList . add ( this . active_class ) ;
273
- }
266
+ // Group DOM manipulations
274
267
275
- if ( this . options . source === "ajax" ) {
276
- await this . _get_content ( ) ;
277
- // Also initialize content.
278
- // Due to asynchronous ``_onShow`` the content might not be
279
- // available before ``_onMount``.
280
- this . _initialize_content ( ) ;
268
+ if ( this . options . class ) {
269
+ tippy_classes . push ( ...this . options . class . split ( " " ) ) ;
281
270
}
282
- } ,
283
271
284
- _onMount ( ) {
285
- // Notify parent patterns about injected content.
286
- // Do not call pat-inject's handler, because all necessary
287
- // initialization after injection is done here.
288
- $ ( this . tippy . popper ) . trigger ( "patterns-injected" , [
289
- { skipPatInjectHandler : true } ,
290
- this . el ,
291
- this . tippy . popper ,
292
- ] ) ;
272
+ // Add a generic non-tippy related class to identify the tooltip container
273
+ tippy_classes . push ( "tooltip-container" ) ;
293
274
294
275
if ( this . options . closing === "close-button" ) {
295
276
// First, remove previously automatically added close buttons.
@@ -298,7 +279,7 @@ export default Base.extend({
298
279
for ( const close_button of this . tippy . popper . querySelectorAll (
299
280
".pat-tooltip--close-button"
300
281
) ) {
301
- close_button . parentNode . removeChild ( close_button ) ;
282
+ close_button . remove ( ) ;
302
283
}
303
284
304
285
const close_button = document . createElement ( "button" ) ;
@@ -307,18 +288,34 @@ export default Base.extend({
307
288
content . parentNode . insertBefore ( close_button , content ) ;
308
289
}
309
290
310
- if ( this . options . class ) {
311
- for ( let class_ of this . options . class . split ( " " ) ) {
312
- this . tippy . popper . classList . add ( class_ ) ;
313
- }
291
+ // Store reference to method for closing panels on the tooltip element instance.
292
+ tippy_classes . push ( "has-close-panel" ) ;
293
+ dom . set_data ( this . tippy . popper , "close_panel" , this . hide . bind ( this ) ) ;
294
+
295
+ this . tippy . popper . classList . add ( ...tippy_classes ) ;
296
+
297
+ if ( this . options . markInactive ) {
298
+ this . el . classList . remove ( this . inactive_class ) ;
299
+ this . el . classList . add ( this . active_class ) ;
314
300
}
315
301
316
- // Add a generic non-tippy related class to identify the tooltip container
317
- this . tippy . popper . classList . add ( "tooltip-container" ) ;
302
+ if ( this . options . closing !== "auto" && this . options . trigger === "hover" ) {
303
+ // no auto-close when hovering when closing mode is "sticky" or "close-button".
304
+ this . tippy . setProps ( { trigger : "click" } ) ;
305
+ }
318
306
319
- // Store reference to method for closing panels on the tooltip element instance.
320
- this . tippy . popper . classList . add ( "has-close-panel" ) ;
321
- dom . set_data ( this . tippy . popper , "close_panel" , this . hide . bind ( this ) ) ;
307
+ if ( this . options . source === "ajax" ) {
308
+ await this . _get_content ( ) ;
309
+ }
310
+
311
+ // Notify parent patterns about injected content.
312
+ // Do not call pat-inject's handler, because all necessary
313
+ // initialization after injection is done here.
314
+ $ ( this . tippy . popper ) . trigger ( "patterns-injected" , [
315
+ { skipPatInjectHandler : true } ,
316
+ this . el ,
317
+ this . tippy . popper ,
318
+ ] ) ;
322
319
323
320
this . _initialize_content ( ) ;
324
321
} ,
0 commit comments