| 1 |
import Component from './loader/component'; |
| 2 |
|
| 3 |
class AppLoader { |
| 4 |
selector = 'a.elementor-app-link, .elementor-app-link .ab-item'; |
| 5 |
|
| 6 |
constructor() { |
| 7 |
$e.components.register( new Component() ); |
| 8 |
|
| 9 |
window.addEventListener( 'DOMContentLoaded', this.onLoad.bind( this ) ); |
| 10 |
} |
| 11 |
|
| 12 |
onLoad() { |
| 13 |
const links = document.querySelectorAll( this.selector ); |
| 14 |
|
| 15 |
if ( ! links.length ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
links.forEach( ( link ) => { |
| 20 |
link.addEventListener( 'click', ( event ) => { |
| 21 |
event.preventDefault(); |
| 22 |
$e.run( 'app/open', { |
| 23 |
url: link.href, |
| 24 |
} ); |
| 25 |
} ); |
| 26 |
|
| 27 |
link.addEventListener( 'mouseenter', () => { |
| 28 |
$e.run( 'app/load', { |
| 29 |
url: link.href, |
| 30 |
} ); |
| 31 |
} ); |
| 32 |
} ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
window.elementorAppLoader = new AppLoader(); |
| 37 |
|